There are lots of possible ways of doing that. What have you tried so far?
Anurag Malaviya
Greenhorn
Joined: Jul 01, 2009
Posts: 19
posted
0
Matthew Brown wrote:There are lots of possible ways of doing that. What have you tried so far?
i am using a loop to traverse the array and find out the total number of occurrence of all elements .
But its not working properly. Can you suggest any other approach.
It's certainly possible that way - maybe you should show us your code and tell us what's not working. One thing - you might find it easier if you sort the array into ascending order first.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32638
4
posted
0
Or copy the array and sort and search the copy.
Or copy all values into a set; adding values to a Set in Java™ gives a return value which might be helpful.