FastPrepMaximum Subarray Sum
Problems/Maximum Subarray Sum

Maximum Subarray Sum

Omnissa logoOmnissa● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Omnissa onsite interview for a full-time role. The report names the standard maximum-subarray task and Kadane's algorithm. It leaves out the interface and the number limits. We chose those.

Our version is about 99% the same as the reported question.

Given an integer array nums, return the largest possible sum of a non-empty contiguous subarray.

A subarray uses consecutive elements in their original order. You must select at least one element, even when all values are negative. Return the exact sum as a signed 64-bit integer.

Function

maxSubarraySum(nums: int[]) → long

Examples

Example 1

nums = [4,-6,3,2,-1]return = 5

The subarray [3,2] has the largest sum, 5. Extending it left or right decreases the sum.

Example 2

nums = [-4,-2,-7]return = -2

The single-element subarray [-2] is optimal. Choosing no elements is not allowed.

Constraints

  • 1 <= nums.length <= 20000
  • -1000000 <= nums[i] <= 1000000

More Omnissa Onsite Interview questions

  • Build and Check a Palindrome Linked ListONSITE INTERVIEW · Seen Sep 2026
  • Find the CelebrityONSITE INTERVIEW · Seen Sep 2026
  • Maximum All-Ones Square Side LengthONSITE INTERVIEW · Seen Sep 2026
  • Coin ChangeONSITE INTERVIEW · Seen Jul 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Jul 2026
  • Rotate Array RightONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Count Subsets With a Target SumSafe Security · ONSITE INTERVIEW
  • 0/1 Knapsack with Weight and Volume LimitsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Maximum Subarray Sum with One DeletionOracle · ONSITE INTERVIEWOracle interview questions
  • Best Time to Buy and Sell Stock IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Coin ChangeMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Maximum SubarrayUpstart · ONSITE INTERVIEWUpstart interview questions
  • Smallest Sufficient TeamExpedia · ONSITE INTERVIEWExpedia interview questions
  • Maximum Product SubarrayHartford Financial Services · ONSITE INTERVIEWHartford Financial Services interview questions
  • Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
All Omnissa interview questionsSee Omnissa hiring insights
Saved
class Solution {
    public long maxSubarraySum(int[] nums) {
        // Write your code here
    }
}
Checking account…