Print All Distinct Elements of a given integer array | GeeksforGeeks

preview_player
Показать описание


This video is contributed by Shubham Kumar

Please Like, Comment and Share the Video among your friends.

Follow us on Facebook:

And Twitter:

Also, Subscribe if you haven't already! :)
Рекомендации по теме
Комментарии
Автор

I think sorting is not a good idea unless it is asked to print distinct elements in sorted manner.
By sorting, relative order of elements will be lost and hence may fail to pass test cases.

monikakl
Автор

Thanks for the vidoe, Can you share the same logic for Java?

tejkumarkempaiah
Автор

We can also do this efficiently in c++ by taking set, traversing array and checking if that element exist in set or not. If not, then add the element and print the elements.

Chachavimdhayak
Автор

Sorry to say but I am unable to understand ur first code ...I am learning now..start phase

pawanshaw
Автор

We can even use hashMap or sets and get in O(n)

remstondsa
Автор

dude expaline how program work...???en we will get the progrm in google

muddabirnaikodi
Автор

Mic se doori banaye...mic ke andar jaane ki koshish na karein..

InDiAnAjOnEs
Автор

can you write same code in javascript??

rahulnag
Автор

Using HashSet could u pls explain why u have use if condition u can directly add it in hashset and if duplicate values comes it won't add in Hashset as it doesn't allow duplicate.

palaksoni
Автор

Is it possible to do it in O(n) with out using any auxiliary variable(here the set depends upon n and so I don't want any extra such variable)?

Thanks!

rajeshdansena
Автор

can u plz explain why u wrote count << arr[i] << " ";

shivamtiwari