FastPrepMaximum of Subarray Minimums
Problems/Maximum of Subarray Minimums

Maximum of Subarray Minimums

JP Morgan Chase logoJP Morgan Chase● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase intern online assessment. The report does not give the function interface. Our version is about 99% the same as the reported question.

You are given an integer array arr of length n and an integer k.

Consider every contiguous subarray of length k:

  • The first subarray is arr[0..k-1].
  • The next subarray is arr[1..k], and so on.
  • The last subarray ends at index n-1.

For each such subarray, find its minimum value. Among all these minimum values, determine and return the maximum one.

Implement maxOfSubarrayMinimums with these parameters:

  • int[] arr: the input array
  • int k: the length of every contiguous subarray

Return an int: the maximum among the minimum values of all length-k subarrays.

Function

maxOfSubarrayMinimums(arr: int[], k: int) → int

Examples

Example 1

arr = [1,2,3,4,5]k = 2return = 4
  • The length-2 subarrays are [1,2], [2,3], [3,4], and [4,5].
  • Their minimum values are 1, 2, 3, and 4.
  • The maximum of these values is 4.

Constraints

  • 1 <= n <= 10^6
  • 1 <= arr[i] <= 10^9 for 0 <= i < n
  • 1 <= k <= n

More JP Morgan Chase Online Assessment questions

  • Find Total CostOA · Seen Oct 2026
  • Minimum Meeting RoomsOA · Seen Oct 2026
  • Count Dropped RequestsOA · Seen Oct 2026
  • Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
  • Task SchedulingOA · Seen Oct 2026
  • Substring RemovalOA · Seen Oct 2026
  • Maximum Game Board ScoreOA · Seen Sep 2026
  • Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
  • Same Substring Within BudgetOA · Seen Sep 2026
  • Invert Ad Visibility BitsOA · Seen Aug 2026

Similar questions at other companies

  • Minimum of Fixed-Window MaximaJuspay · OA
  • Profit AnalysisVirtu Financial · OAVirtu Financial interview questions
  • Most Negative Number in Each WindowWells Fargo · OAWells Fargo interview questions
  • Maximum of Fixed-Window MinimaRoblox · OARoblox interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Sliding Window Maximum in a MatrixCitadel · OACitadel interview questions
  • Maximum Earnings Across WarehousesAmazon · ONSITE INTERVIEW
  • Longest Subarray Within an Absolute-Difference LimitGoogle · ONSITE INTERVIEWGoogle interview questions
  • Longest Continuous Subarray Within an Absolute-Difference LimitUber · ONSITE INTERVIEWUber interview questions
  • Disk Space Window AnalyzerAgoda · PHONE SCREENAgoda interview questions

JP Morgan Chase interview experiences

  • JPMorgan Chase Experienced SWE Java Interview: 1 Experience
  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int maxOfSubarrayMinimums(int[] arr, int k) {
      // Write your code here.
    }

}
Checking account…