This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Find biggest 2 numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Find biggest 2 numbers" Watch "Find biggest 2 numbers" New topic
Author

Find biggest 2 numbers

kavitha vasu
Ranch Hand

Joined: Feb 22, 2007
Posts: 70
Hi friends,

Yesterday I have attended one interview , I got question like these,


3,4,5,67,1,67,233,466

How to find biggest of 2 numbers amoung these numbers .

Should not use any sorting algorithm
also they asked me to use any collection classes.
Also how to find duplicate of these numbers

Please any one help me to get solution for this.

Thanks
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Kavitha, you got to read Collection API from Thinking In Java !!
[ March 03, 2008: Message edited by: Chetan Parekh ]

My blood is tested +ve for Java.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

hi,

in collection class,TreeSet class is there,which avoid dupulicatevalue and also it will arrage the datas in ascending order..so last number is greatest number,and prvious one is 2nd greatest number

note:which class implements set interface always has the above properties

thanks & regards,

seetharaman
kavitha vasu
Ranch Hand

Joined: Feb 22, 2007
Posts: 70
Hi



Here i have to find the which is duplicate number and that should be printed on screen.

How to do that?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Find biggest 2 numbers