When you take a problem from a challenge site, it is a good idea to say it and give link:
Quote:i am not getting any idea..pls help me
Those callenges are always about crafting an ad-hoc algorithm for the problem.
The first step is to solve the problem by hand with a small dataset.
Start brute force, then refine the algorithm, then take a bigger dataset to check if it still works.
Last step is to translate manual algorithm to code.
Usually, those challenges are about testing your knowledge in algorithms and data structures.