commit db83ec26cb04c037bd48bfaa9a824ff56f108183
parent 9626ead947fb0659888ed06de10b4cc83e9689d7
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Sat, 18 Mar 2023 17:37:26 +0100
Random Problem
Diffstat:
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/Problems/0050.cpp b/Problems/0050.cpp
@@ -0,0 +1,8 @@
+class Solution {
+public:
+ double myPow(double x, int n) {
+ if (n == 0) return 1;
+ if (n < 0) return 1 / x * myPow(1 / x, -(n + 1));
+ return (n % 2 == 0) ? myPow(x * x, n / 2) : x * myPow(x * x, n / 2);
+ }
+};
diff --git a/README.md b/README.md
@@ -65,6 +65,7 @@ for solving problems.
| 0047 | Medium | [Permutations II ](Problems/0047.cpp) |
| 0048 | Medium | [Rotate Image](Problems/0048.cpp) |
| 0049 | Medium | [Group Anagrams](Problems/0049.cpp) |
+| 0050 | Medium | [Pow(x, n)](Problems/0050.cpp) |
| 0053 | Medium | [Maximum Subarray](Problems/0053.cpp) |
| 0054 | Medium | [Spiral Matrix](Problems/0054.cpp) |
| 0055 | Medium | [Jump Game](Problems/0055.cpp) |