← All problemsSign in

GOOD NUMBERS

Given an array,$A$ , having $N$ integers $A1,A2,A3...$ .Two elements of the array and are called similar iff $Ai = Aj + 1$ or $Aj = Ai +1$ . Also, the similarity follows transitivity. If $Ai$ and $Aj$ are similar and $Aj$ and $Ak$ are similar, then $Ai$ and $Ak$ are also similar. Note:$i ,j ,k$ and are all distinct. You need to find the number of pairs of indices$(i, j)$ such that $i$< $j

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start