Untitled
unknown
plain_text
2 years ago
414 B
27
Indexable
class Solution {
public:
double myPow(double x, int n) {
if(n==0) return 1;
if(n == INT_MIN){
x = x * x;
n = n/2;
}
if(n<0){
x = 1/x;
n = -n;
}
double res = myPow(x, n/2);
if(n%2){
return res * res * x;
}
else{
return res*res;
}
}
};Editor is loading...
Leave a Comment