Member-only story

Maximum Circular Subarray Sum | Coding Interview | Arrays

Ganesh Prasad
5 min readSep 6, 2021

--

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

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: 34
Explanation: 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

--

--

Ganesh Prasad
Ganesh Prasad

Written by Ganesh Prasad

Backend Developer at Appscrip | C++ veteran, 💜 Dart

No responses yet