leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0050.cpp (237B)
0 class Solution { 1 public: 2 double myPow(double x, int n) { 3 if (n == 0) return 1; 4 if (n < 0) return 1 / x * myPow(1 / x, -(n + 1)); 5 return (n % 2 == 0) ? myPow(x * x, n / 2) : x * myPow(x * x, n / 2); 6 } 7 };