Test Case not considered


  • 2
    A

    The test case with n = INT_MIN and x between 0 to 1 is not considered.
    My answer is accepted with this if condition at the beginning

    if ( n == INT_MIN){
       if (x==1.0 || x== -1.0){
           return 1.0;
       }
       else{
           return 0.0;
       }
    }
    

    which is incorrect. Please add a test case.


  • -1
    P

    In principle double precision has 52 sig-figs in binary expression, which is larger than int (31). That means pow(x, INT_MIN) could be any value as long as x is closer enough to +-1.

    So perhaps the only workaround is to calculate pow(x, INT_MIN+1)/x, if the algorithm has utilized the Math.abs() function.

    That could make some nasty corner cases.


Log in to reply
 

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