dimanche 4 novembre 2018

Finding the Index of duplicates and finding those index in array as elements

I was trying to solve a question in competitive coding site, where i got stuck in one of the problems. We You need to determine if it is possible to choose two indices i and j such that V(i)≠V(j), but V(V(i)) = V(V(j)).

For Example : If the array is: 5 5 1 2. We have 5 which is repeating, and is present in indices 1 and 2, which are present in the array.(Here indexing starts from 1)

Please help me with problem. Solutions in C++ would be preferred.

Aucun commentaire:

Enregistrer un commentaire