FastPrepMaximum Sum of a Contiguous Subarray
Problems/Maximum Sum of a Contiguous Subarray

Maximum Sum of a Contiguous Subarray

LinkedIn logoLinkedIn● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a LinkedIn phone screen. The named task matches the reported one at about 90%. The report has no function signature, limits or examples. We chose those.

Given an integer array nums, return the largest sum of any nonempty contiguous subarray. A contiguous subarray uses every element from one chosen start position through one chosen end position.

Return only the maximum value. Different subarrays may attain it. A singleton is allowed; choosing no elements is not. Do not change the input.

Function

maximumSubarraySum(nums: int[]) → int

Examples

Example 1

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

The contiguous block [6,-1,2] has sum 7, which is larger than the sum of every other contiguous block.

Example 2

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

A nonempty block is required. The singleton [-3] has the largest sum; choosing no elements is not allowed.

Example 3

nums = [5]return = 5

The only nonempty block contains 5 and has sum 5.

Constraints

  • For this exercise, assume 1 <= nums.length <= 1000.
  • For this exercise, assume -1000000 <= nums[i] <= 1000000.

More LinkedIn Phone Screen questions

  • Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
  • Known Words Matching Phone DigitsPHONE SCREEN · Seen Oct 2026
  • Inverse-Depth Nested List SumPHONE SCREEN · Seen Oct 2026
  • Valid Number with ExponentsPHONE SCREEN · Seen Oct 2026
  • Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Oct 2026
  • Sort a Quadratic-Transformed ArrayPHONE SCREEN · Seen Oct 2026
  • Constant-Time Minimum StackPHONE SCREEN · Seen Oct 2026
  • Randomized String MultisetPHONE SCREEN · Seen Oct 2026
  • Move the Nth Linked-List Node to the FrontPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • 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
  • Match Shops and BuyersGoogle · PHONE SCREENGoogle interview questions
  • Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN
  • Minimum-Cost Color SequenceOpenAI · OA · PHONE SCREENOpenAI interview questions

LinkedIn interview experiences

  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Experienced MLE Onsite: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public int maximumSubarraySum(int[] nums) {
        // Write your code here.
    }
}
Checking account…