Method 1:
-----------------
1. sort ur array
2. make a string as csv from the array elements
3. for each number in ur sorted array, check if the indexOf() and lastIndexOf() from the string return same values. Return at the first number that does so, that's ur answer.
Method 2:
--------------
In step 1 of method 1, don't store duplicates and the smallest number shall be answer after sorting itself.
Method 3:
--------------
1. Make a wrapper of all ur numbers and insert in a collection.
2. use the collection's sort method to sort them.
3. check for every number if it exists at some other index as well as the one being checked. Return the first number that dissatisfies the condition