3 ms C++ Solution Beats 100%


  • 0
    A

    My solution that, to my surprise, had such a good performance

    int trailingZeroes(int n) {
         int zeros = 0;
         int i = 1;
         int curr = 0;
         while(1){
         curr = (n)/(pow(5,i));
         if(curr<1) break;
            zeros+=curr;
            i++;
         }
            
         return zeros;
        }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.