Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.util.Hashtable;
  2. import java.util.Map.Entry;
  3. public class repeated_num {
  4.  
  5.     public static void main(String[] args) {
  6.         int []arr={1,2,1,4,5,6,4,2,1};
  7.         Hashtable<Integer,Boolean > ht = new Hashtable<Integer,Boolean >();
  8.  
  9.         for(int i=0;i<arr.length;i++)
  10.             if(ht.get(arr[i]) == null)
  11.                 ht.put(arr[i],false);
  12.             else
  13.                 ht.put(arr[i], true);
  14.        
  15.        
  16.        
  17.         for (Entry<Integer, Boolean> entry : ht.entrySet()) {
  18.             Integer key = entry.getKey();
  19.             Boolean value = entry.getValue();
  20.             if(value)
  21.                 System.out.println(key);
  22.            
  23.            
  24.         }
  25.  
  26.  
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement