← All problemsSign in

Animesh has a war with tribal leader Malvika

Malvika is the leader of a large tribal army, with soldiers from multiple tribes. There are a total of $n$ soldiers in the army. You are given an array $a$ of length $n$, where $a[i]$ denotes the tribe number of the $i^{th}$ soldier. Now Animesh, the leader of the neighboring tribe and staunch enemy of Malvika, has attacked her army and declared a war which would later be regarded as the greatest

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