Citrix System Inc Interview Question
Quality Assurance EngineersTeam: Xen-Client
Country: India
Interview Type: In-Person
The above would be feasible if there are asking for duplicates in Alphabets but the question is for number so if the array contains {1,3,4,10000,9000,10000,8}
so now the map has to contain 10000 elements which is just wasteful in our case where we are trying to find the duplicates for only 5 elements .
Use a map, initialize it to 0.
- Sasi March 09, 2012Then iterate over the array incrementing the value of map.
Now re-iterate and if the value of any map is greater than 1 then duplicates exist. So print the number out.