FastPrepMaximum MEX by Decreasing Values
Problems/Maximum MEX by Decreasing Values

Maximum MEX by Decreasing Values

IMC Trading logoIMC Trading● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IMC Trading new grad online assessment. Our version is about 95% the same as the original screenshot. We set limits on the array numbers because they were outside the part that was captured.

You are given an integer array arr. One operation replaces any element arr[i] by an integer x satisfying 0 <= x <= arr[i]. You may perform any number of operations.

The MEX of an array is the smallest nonnegative integer absent from it. Return the maximum MEX achievable after these operations.

Function

getMaximumMEX(arr: int[]) → int

Examples

Example 1

arr = [3,2,3]return = 3

Each element can supply any nonnegative number no greater than its original value. Build the longest prefix of distinct values starting at 0.

Example 2

arr = [0,1,1,3]return = 3

Each element can supply any nonnegative number no greater than its original value. Build the longest prefix of distinct values starting at 0.

Example 3

arr = [0,0,0]return = 1

Each element can supply any nonnegative number no greater than its original value. Build the longest prefix of distinct values starting at 0.

Constraints

  • 1 <= arr.length <= 2 * 10^5
  • 0 <= arr[i] <= 10^9

More IMC Trading Online Assessment questions

  • Earliest Meeting Start on a 24-Hour ClockOA · Seen Nov 2026
  • Grid Paths with Override PassesOA · Seen Oct 2026
  • Weighted LFU CacheOA · Seen Sep 2026
  • Rock JumpingOA · Seen Aug 2026
  • Stack Batch RemovalOA · Seen Aug 2026
  • Chain of CommandOA · Seen Aug 2026
  • Choose ContainersOA · Seen Aug 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Can Every Package Fit in a BoxOA · Seen Jul 2026

Similar questions at other companies

  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Maximize Minimum Deployment DifficultyJP Morgan Chase · OAJP Morgan Chase interview questions
  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
  • Maximize Center A Package BenefitAmazon · OA
  • EV Charging Cost OptimizationTata Consultancy Services · OATata Consultancy Services interview questions
  • Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions

Interview reports that mention this question

  • IMC Trading OA: What It Tests (2026)

IMC Trading interview experiences

  • IMC Trading SWE OA and Video: 18 Experiences (Part 3 of 3)
  • IMC Trading SWE OA Questions: 22 Experiences (Part 2 of 3)
  • IMC SWE New Grad OA and Interviews: 58 Experiences (Part 1 of 3)
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public int getMaximumMEX(int[] arr) {
        // Write your solution here.
    }
}
Checking account…