Created
March 12, 2024 06:27
-
-
Save vamsitallapudi/8c706c63bb8bec45deab2a438053b54a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public int maxSubArray(int[] nums) { | |
int currMax = nums[0]; | |
int overallMax = nums[0]; | |
for(int i = 1; i< nums.length;i++) { | |
currMax = Math.max(nums[i], currMax+nums[i]); | |
overallMax = Math.max(currMax, overallMax); | |
} | |
return overallMax; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment