I am getting NZEC in the problem Flow004. I am using Java and this is my code. I searched for this and found some answers but I still couldn’t resolve it. When I tried it using some custom inputs too, it worked fine. Could someone please help?
- For last digit sum = num % 10
- for first digit:
loop -> i = 1 - 6
if num <= 9 break;
//first and last digits will be same for single digit numbers
else if (num / 10 ^ i <= 9) sum = sum + num / 10 ^ 9 break;
//dividing num by (10, 100, 1000,…,1000000) if quotient is <=9 then it is first digit