create empty set that stores the visiting element of array . Refer below post for details of unordered_set https : www . geeksforgeeks . org / unorderd_set - stl - uses /
HashSet < Integer > s = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) {