Maximum Subarray with Start and End Windows
Updated
Problem statement
You are given an integer array and several queries [x1, y1, x2, y2], all using 1-based inclusive indices. For each query, choose a start index i in [x1, y1] and an end index j in [x2, y2], with i <= j.
Return the maximum sum of the contiguous subarray from i through j for every query.
Function
maximumWindowSubarraySums(values: int[], queries: int[][]) → long[]Examples
Example 1
values = [10,-40,-30,30,40]queries = [[1,3,3,5],[2,4,3,5]]return = [40,70]The first query chooses days 3 through 5, while the second chooses days 4 through 5.
Constraints
1 <= values.length, queries.length <= 100000-10^9 <= values[i] <= 10^9- Every query satisfies
1 <= x1 <= y1 <= values.length,1 <= x2 <= y2 <= values.length,x1 <= x2, andy1 <= y2.
Source note: Interview prompt excerpt preserved as source evidence.
More InMobi Online Assessment questions
- Validate a Bracket SequenceOA · Seen Oct 2026
- Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
- Minimum Service Cold StartsOA · Seen Oct 2026
- Range Maximum Subarray Sum QueriesOA · Seen Oct 2026
- Connected Components with Divisor ThresholdOA · Seen Aug 2026
- Maximize Impression ValueOA · Seen Aug 2026
- Supply Path OptimizationOA · Seen Aug 2026
- Delivery ServiceOA · Seen Jun 2026
- Shared InterestOA · Seen Jun 2026
- Temporal AnomaliesOA · Seen Jun 2026
Similar questions at other companies
- Maximize Shipment Order by Sorting One WindowAmazon · OA
- Distribute Elements Into Two Arrays IIRubrik · OARubrik interview questions
- Count Pairs with K Divisible Values in the IntervalChubb · OAChubb interview questions
- Most Items Within Budget from a Start IndexHudson River Trading · OAHudson River Trading interview questions
- Binary Sorting Rounds After FlipsVisa · OAVisa interview questions
- Minimum Snapshots for a Version TreeAdobe · OAAdobe interview questions
- Longest Subarray with Sum at Most KGoogle · OAGoogle interview questions
- Minimum Sorted Erasure OperationsAtlassian · OAAtlassian interview questions
- Segment QueriesTikTok · OATikTok interview questions
- Maximum Laptop Rating in a Price RangePostman · OAPostman interview questions