FastPrepChoose One from Each Set to Minimize the Range
Problems/Choose One from Each Set to Minimize the Range

Choose One from Each Set to Minimize the Range

InMobi logoInMobi● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an InMobi full-time online assessment. The report gives the goal and one worked example. It does not give limits on the numbers. Our version is about 98% the same as the reported question.

You are given several non-empty integer sets, represented as an array sets. Every set contains the same number of integers. Choose exactly one integer from each set.

The range of a selection is the difference between its maximum and minimum selected values.

Return the minimum possible range over all valid selections.

Function

minimumSelectionRange(sets: int[][]) → long

Examples

Example 1

sets = [[30,20,10,40],[22,33,44,99],[16,17,18,19]]return = 3

Choose 20, 22, and 19. The range is 22 - 19 = 3, and no selection has a smaller range.

Example 2

sets = [[1,5],[4,8]]return = 1

Choosing 5 from the first set and 4 from the second produces range 1.

Example 3

sets = [[-5],[10],[3]]return = 15

Every set has only one choice, so the range is 10 - (-5) = 15.

Constraints

  • 1 ≤ sets.length ≤ 1,000
  • 1 ≤ sets[i].length
  • sets[i].length = sets[0].length for every valid i.
  • The total number of integers across all sets is at most 200,000.
  • Every value fits in a signed 32-bit integer.

More InMobi Online Assessment questions

  • Validate a Bracket SequenceOA · Seen Oct 2026
  • Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
  • Maximum Subarray with Start and End WindowsOA · 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

Similar questions at other companies

  • Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Sliding Window MedianAuxoAI · OA
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Minimum Meeting RoomsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Meeting Rooms IIWise · OA
  • Maximum Requests in WindowSalesforce · OASalesforce interview questions
  • Minimum Parking Roof LengthAmerican Express · OAAmerican Express interview questions
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
All InMobi interview questionsSee InMobi hiring insights
Saved
class Solution {
    public long minimumSelectionRange(int[][] sets) {
      // write your code here
    }
}
Checking account…