Kadane's algorithm

Maximum Sum Circular Subarray

January 23, 2024
medium
Kadane's algorithm

Problem Statement # Given a circular integer array nums (the last element is connected to the first element), find the maximum possible sum of a non-empty subarray of nums. Example: Input: nums = [5, -3, 5] Output: 10 Explanation: Subarray [5, 5] has maximum sum 5 + 5 = 10. Solution Approach # The solution involves finding the maximum subarray sum using Kadane’s algorithm. Since the array is circular, the maximum sum may wrap around the end of the array. ...