You are getting TLE because of the wrong implementation of this loop.
while (fon >= 0) {
if (fon%10 == 0) {
count++;
}
fon = fon/10;
}
The smallest value of fon in the loop will be zero, now a/c to the condition the loop should run for zero too, and this time fon=fon/10 will have no effect on it thus the value of fon remains 0 for next loop and so on, making it run infinitely.
1 Like
- Your loop condition is wrong because βfon is greater and equal to 0β. here you have to remove the equal condition and code be like this,
while (fon > 0) {}.