25. Maximum Circular Subarray Sum
β GFG solution to the Maximum Circular Subarray Sum problem: find maximum subarray sum in circular array using Kadane's algorithm with circular optimization. π
π§© Problem Description
π Examples
Example 1
Input: arr[] = [8, -8, 9, -9, 10, -11, 12]
Output: 22
Explanation: Starting from the last element of the array, i.e, 12, and moving in a circular fashion,
we have max subarray as 12, 8, -8, 9, -9, 10, which gives maximum sum as 22.Example 2
Input: arr[] = [10, -3, -4, 7, 6, 5, -4, -1]
Output: 23
Explanation: Maximum sum of the circular subarray is 23. The subarray is [7, 6, 5, -4, -1, 10].Example 3
π Constraints
β
My Approach
Kadane's Algorithm + Circular Optimization
Algorithm Steps:
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
π§βπ» Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated