Wht time limited exceed in this C code?

  • 0

    int maxDiv(int a, int b);
    bool isUgly(int num) {

     int no=0;
     no = maxDiv(num,2);
     no = maxDiv(no,3);
     no = maxDiv(no,5);
     return (no == 1) ? 1:0;


    int maxDiv(int a, int b)
    a = a/b;
    return a;

  • 0

    when num's value is 0, then maxDiv function get a dead loop.

Log in to reply

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