Frequency Array Retrieval
Consider an array $A$ consisting of $N$ positive elements. The *frequency array* of $A$ is the array $B$ of size $N$ such that $B_i =$ *frequency* of element $A_i$ in $A$. For example, if $A = [4, 7, 4, 11, 2, 7, 7]$, the *frequency array* $B = [2, 3, 2, 1, 1, 3, 3]$. You have lost the array $A$, but fortunately you have the array $B$. Your task is to construct the **lexicographically smallest
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start