Distinct Values
The *beauty* value of an array is defined as the difference between the largest and second largest elements of the array. Note that the largest and second largest elements can have the same value in case of duplicates. For example, *beauty* value of $[2, 5, 3, 1] = 5 - 3 = 2$ and *beauty* value of $[7, 6, 7] = 7 - 7 = 0$ You are given an array $A$ of length $N$. Your task is to find the total n
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