Created
February 23, 2026 16:23
-
-
Save varenya/5ebda875032ac1ae10a16de2863c7bf8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function maxSubArraySum(input: number[]): number { | |
| let maxSum = input[0]; | |
| let maxEnding = input[0]; | |
| for (let i = 1; i < input.length; i++) { | |
| maxEnding = Math.max(maxEnding + input[i], input[i]); | |
| maxSum = Math.max(maxSum, maxEnding); | |
| } | |
| return maxSum; | |
| } | |
| export { maxSubArraySum }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment