Tap here to switch tabs
Problem
Submissions

Problem: Lexicographically Maximum MEX Array

Try to solve the Lexicographically Maximum MEX Array problem.

Statement

You are given an integer array nums.

You want to partition nums into contiguous subarrays by repeatedly selecting a non empty prefix from the remaining elements of nums, appending the MEX of the selected prefix to a result array, and removing that prefix from nums until nums becomes empty.

Return the lexicographically largest result array that can be formed.

Note: The MEX (minimum excluded value) of an array is the smallest non negative integer that does not appear in the array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Lexicographically Maximum MEX Array

Try to solve the Lexicographically Maximum MEX Array problem.

Statement

You are given an integer array nums.

You want to partition nums into contiguous subarrays by repeatedly selecting a non empty prefix from the remaining elements of nums, appending the MEX of the selected prefix to a result array, and removing that prefix from nums until nums becomes empty.

Return the lexicographically largest result array that can be formed.

Note: The MEX (minimum excluded value) of an array is the smallest non negative integer that does not appear in the array.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤105\leq 10^5