Explicitly handle first digit and call recursive function findNDigitNumsUtil for remaining indexes . Note that the first digit is considered to be present in even position .
for ( int i = 1 ; i <= 9 ; i ++ ) { out [ index ] = i + '0' ; findNDigitNumsUtil ( n , out , index + 1 , evenSum + i , oddSum ) ; } }