FastPrepMaximum Subarray
Problems/Maximum Subarray

Maximum Subarray

Google logoGoogle● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names Kadane's algorithm. It does not give the exact variant, the interface, or the overflow limits. This maximum-subarray task is about 78% the same as the reported question.

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

The result is a signed 64-bit integer.

Function

maxSubarraySum(nums: int[]) → long

Examples

Example 1

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

The contiguous subarray [4, -1, 2, 1] has the maximum sum, 6.

Example 2

nums = [-8,-3,-6]return = -3

A valid subarray must be non-empty, so the best choice is the single value -3.

Constraints

  • 1 <= nums.length <= 200000
  • -10^9 <= nums[i] <= 10^9

More Google Phone Screen questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Maximum Subarray Sum with One DeletionServiceNow · PHONE SCREENServiceNow interview questions
  • Maximum Product of a Contiguous SubarrayLinkedIn · PHONE SCREENLinkedIn interview questions
  • Fewest Coins CombinationBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions
  • Jump GamePaytm · PHONE SCREENPaytm interview questions
  • Query Words Within K PositionsPalantir · PHONE SCREENPalantir interview questions
  • House RobberVisa · PHONE SCREENVisa interview questions
  • Best Improvement Period of at Least K IntervalsAmazon · PHONE SCREEN
  • Longest Increasing SubsequenceAngel One · PHONE SCREEN
  • Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long maxSubarraySum(int[] nums) {
        // write your code here
    }
}
Checking account…