Maximum Subarray Sum Problem Statement

Given an array arr of length N consisting of integers, find the sum of the subarray (including empty subarray) with the maximum sum among all subarrays.

Explanation:

A subarray is a contiguous segment of an array, meaning it can be formed by removing 0 or more integers from the start, and 0 or more integers from the end of the array.

Input:

N
arr[0] arr[1] ... arr[N-1]

Output:

The sum of the maximum subarray.

Example:

Input:
N = 5
arr = [-2, 1, -3, 4, -1]
Output:
4
Explanation:

The maximum subarray sum is obtained by the subarray [4] which has the sum 4.

Constraints:

  • 1 <= N <= 10^6
  • -10^6 <= arr[i] <= 10^6
Note:

The sum of an empty subarray is considered 0.

AnswerBot
3mo

Find the sum of the subarray with the maximum sum among all subarrays in an array of integers.

  • Iterate through the array and keep track of the maximum sum subarray encountered so far.

  • Use Kadane's algor...read more

Boggula Venkata Ajith Reddy
6mo
Hamburger Menu AmbitionBox Logo Search community Asked inInfosys,System Engineer Maximum Subarray Sum You are given an array (ARR) of length N, consisting of integers. You have to find the sum of the ...read more
Anonymous
6mo
Maximum Subarray Sum You are given an array (ARR) of length N, consisting of integers. You have to find the sum of the subarray (including empty subarray) having maximum sum among all subarrays. A sub...read more
Boggula Venkata Ajith Reddy
6mo
Divide And Conquer Approach Divide the array into 2 halves. Get the answer of left and right parts of the array by recursion. Get the answer of Maximum subarray sum such that the subarray crosses the ...read more
Boggula Venkata Ajith Reddy
6mo
Hamburger Menu AmbitionBox Logo Search companycommunity Asked inInfosys,System Engineer Maximum Subarray Sum You are given an array (ARR) of length N, consisting of integers. You have to find the sum ...read more
Select
Add answer anonymously...

Infosys System Engineer interview questions & answers

A System Engineer was asked 1w agoQ. What are some Java frameworks, and what are the differences among them?
A System Engineer was asked 1mo agoQ. What are the key concepts of Object-Oriented Programming (OOP)?
A System Engineer was asked 1mo agoQ. What is polymorphism?

Popular interview questions of System Engineer

A System Engineer was asked 4d agoQ1. What are the fundamental concepts of coding?
A System Engineer was asked 1w agoQ2. What are some Java frameworks, and what are the differences among them?
A System Engineer was asked 1mo agoQ3. What are the key concepts of Object-Oriented Programming (OOP)?

Top HR questions asked in Infosys System Engineer

A System Engineer was asked 2mo agoQ1. Explain your project.
A System Engineer was asked 3mo agoQ2. Explain your final semester project.
A System Engineer was asked 3mo agoQ3. What was your involvement in your college project?
Infosys System Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits