Member-only story
Maximum Circular Subarray Sum | Coding Interview | Arrays
In this article, I will explain the Maximum Circular Subarray Sum problem, which has been asked by Amazon and Microsoft.
The algorithm requires you to find the Maximum Subarray Sum (without the wrapping around part), also known as Kadane’s algorithm. Hence, we will discuss it first, and then we will use the kadane’s algorithm to solve the main problem.
We will discuss the code with an example in detail and its time and space complexity.
This article is part of the 30 Days preparation plan for coding interviews.
Table of Contents
- Description
- Prerequisite — Kadane’s Algorithm
- Algorithm to find the Maximum circular subarray sum
- Code with explanation
- Time and Space Complexity
Description
Given an array of integers, find the maximum subarray sum where going circular is allowed.
Example:
Input: [11, 1, -17, 2, -15, 9, 13]
Output: 34Explanation: The circular contigious subarray [9 13 11 1] is giving the maximum sum as 34.
In the next section, we will learn the kadane’s algorithm using an animation.
Do you want to stay updated on Coding interview tips and new Questions? Please click on subscribe button to get an email when the new tutorial is…