Loading Question...
Given an array arr of size n, repeatedly perform the following until the array becomes empty:
k such that 1 <= k <= current length of arr.k elements.result.k elements from arr.
Return the lexicographically largest possible result array.MEX({1,2,3}) = 0MEX({0,1,2,4,5}) = 3n = 4
arr = [0,1,1,0]
k = 2 => MEX({0,1}) = 2
arr = [1,0]
result = [2]
k = 2 => MEX({1,0}) = 2
arr = []
result = [2,2]
1 <= n <= 100