Data Structure used

I used HashSet to implement the solution .

Is there any advantage to use hashMap over HashSet or vice versa?

Hey @vishakha_narang
Both have their unique functionalities.
You need sets when basically you just want to store single property of your data . Maps are just an extension of sets where you can add various other properties as well along with your key data. Maps are generally used in place of unordered_maps(HASH_TABLES) to improve the cases where collision might occur in hashtables.
For More info read this :
https://www.geeksforgeeks.org/set-vs-map-c-stl/#:~:text=Differences%3A,value%20needed%20for%20a%20key.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.