Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help in knowing how the code works

 
krishna kumar.s
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The below code produces the unique numbers if numbers 2 to 100 are powered by 2 to 100 i.e 2 pow 2 2 pow 3..... 100 pow 100 . But i am not understanding how the code eliminates duplicates .
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
krishna kumar.s wrote:But i am not understanding how the code eliminates duplicates .

Hint: What data structure are you using to store your data(i.e. x pow x)?
 
krishna kumar.s
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it the Hash set only takes unique values
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
krishna kumar.s wrote:I got it the Hash set only takes unique values

ANY java.util.Set (←click) only stores unique values. You can give it any value you like.

Winston
 
krishna kumar.s
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Anayonkar Shivalkar and Winston Gutkowski thanks a lot for your input .

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic