Google onsite Interview
Anonymous User
5438

Given an array of integers, find a subarray with maximum sum?

Solved using Kadane's Algorithm

Follow up:
Given an array of integers nums, find indexes [i, j] such that the subarray sum nums[i] + nums[i+1] ... nums[j-1] + nums[j] is maximum and nums[i] is equal to nums[j]

Example:

nums = [1, 3, 5, 6, 3, -6, 3]

Answer: [1, 4]

Comments (22)