Works on "Run Code'" but does not work on 'Submit' showing 'Time limit exceeded'
public class Solution {
    public double MyPow(double x, int n) {
        double m=1;
        if(n==0 || x==1.00000){
            return 1.00000;
        }
        else if(n>0){
            while(n>0){
                m*=x;
                n--;
            }
            return m;
        }
        else{
            while(n<0){
                m*=x;
                n=n+1;
            }
            return 1/m;
        }
    }
}

I run it and it works fine with the test case '2.00000
-2147483648' but it doesn't work with that test case when i submit the code.

image

image

Comments (4)