Bug Report for https://neetcode.io/problems/pow-x-n
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Solution accepted even though it fails manually added test case x = 0, n = 0.
class Solution {
public double myPow(double x, int n) {
double res = 1;
if(n < 0){
x = 1 / x;
n *= -1;
}
for(int i = 0; i < n; i++) {
res = res * x;
}
return res;
}
}
Bug Report for https://neetcode.io/problems/pow-x-n
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Solution accepted even though it fails manually added test case x = 0, n = 0.
class Solution {
public double myPow(double x, int n) {
double res = 1;
if(n < 0){
x = 1 / x;
n *= -1;
}
for(int i = 0; i < n; i++) {
res = res * x;
}
return res;
}
}