DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
hard
Array

Maximum Sum Circular Subarray

**Problem Statement:** Given a circular integer array `nums` of length `n`, return the maximum possible sum of a non-empty subarray of `nums`. **Hint / Expected Approach:** Kadane normal + total sum − Kadane min **Edge Cases to Consider:** - (1) All negative numbers - (2) Single element - (3) Wrap-around gives same sum as non-wrap

Examples

Example 1
Input: [1,-2,3,-2]
Output: 3
Example 2
Input: [5,-3,5]
Output: 10
Example 3
Input: [-3,-2,-3]
Output: -2

Constraints

  • ▪1 <= nums.length <= 10^4
  • ▪-10^9 <= nums[i] <= 10^9
  • ▪Time complexity should be O(n) or O(n log n)

Watch Out For Edge Cases

  • ▪All negative numbers
  • ▪Single element
  • ▪Wrap-around gives same sum as non-wrap
Frequently Asked At
GoogleAmazonMicrosoftAdobe