We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 229181c commit 34c8ea2Copy full SHA for 34c8ea2
solution/053.Maximum Subarray/Solution.js
@@ -0,0 +1,9 @@
1
+const maxSubArray = function(nums){
2
+ if(nums.length === 0) return 0;
3
+ let ans = nums[0], tmp = nums[0];
4
+ for(let i = 1; i < nums.length; i++){
5
+ tmp = Math.max(tmp+nums[i], nums[i]);
6
+ ans = Math.max(ans,tmp);
7
+ }
8
+ return ans;
9
+}
0 commit comments