Menu
Coddy logo textTech

Maximum Sum Circular Subarray

Lesson 3 of 3 in Coddy's Interview Coding Challenges - Pack IX course.

challenge icon

Challenge

Hard

Write a function named maxSubarraySumCircular that, given a circular integer array (i.e., the next element of the last element is the first element of the array), returns the sum of the subarray (containing at least one number) that has the maximum sum.

For example,

Input: [5, -3, 5]
Output: 10
Explanation: Subarray [5, 5] has the maximum sum 10.

Constraints:

  • n == nums.length
  • 1 <= n <= 3000
  • -3000 <= nums[i] <= 3000

Try it yourself

int maxSubarraySumCircular(int* nums, int numsSize) {
    // Write code here
}

All lessons in Interview Coding Challenges - Pack IX

1Challenges

Rotate ArrayProduct Array Except SelfMaximum Sum Circular Subarray