We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 317a4ea commit 5355058Copy full SHA for 5355058
50. Pow(x, n).js
@@ -0,0 +1,22 @@
1
+var myPow = function(x, n) {
2
+ if(x == 1){return 1}
3
+ if(n == 0){return 1}
4
+ if(x == -1){
5
+ if(n%2 == 0){return 1}
6
+ else{return -1}
7
+ }
8
+ let k = x
9
+ if(n > 1){
10
+ while( n > 1){
11
+ x *= k
12
+ n--
13
14
+ return x
15
+ }else{
16
+ while( n < 1){
17
+ x *= 1/k
18
+ n++
19
20
21
22
+};
53. Maximum Subarray.js
@@ -0,0 +1,10 @@
+var maxSubArray = function(nums) {
+ let ans = -9999999
+ let sum = 0
+ for(let i = 0 ; i < nums.length; i ++){
+ sum+=nums[i]
+ ans=Math.max(sum,ans)
+ sum=Math.max(sum,0)
+ return ans
0 commit comments