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

Maximum Product 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 product 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

maximumProduct(nums: int[]) → int

Examples

Example 1

nums = [4,-3,-2,1]return = 24

The contiguous block [4,-3,-2] has product 24. Including the final 1 keeps that product. No other contiguous block has a larger product.

Example 2

nums = [0,-5,0]return = 0

Each block containing a zero has product 0. The only nonzero singleton is -5, so 0 is the largest product.

Example 3

nums = [-4]return = -4

The array has one nonempty block, whose product is -4.

Constraints

  • For this exercise, assume 1 <= nums.length <= 200.
  • For this exercise, assume -10 <= nums[i] <= 10.
  • For this exercise, assume the product of every nonempty contiguous subarray fits a signed 32-bit integer: -2147483648 <= product <= 2147483647.

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 Sum 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 maximumProduct(int[] nums) {
        // Write your code here.
    }
}
Checking account…