public int singleNumber(int[] nums) {
        HashMap<Integer,Integer> hashMap =new HashMap<Integer, Integer>();
        for (int i : nums) {
            if (hashMap.containsKey(i)) {
                hashMap.put(i, hashMap.get(i) + 1);
            } else {
                hashMap.put(i, 1);
            }
        }
        int num = 0;
        for (Map.Entry<Integer, Integer> entry: hashMap.entrySet()) {
            int key = entry.getKey();
            int val = entry.getValue();
            if (val == 1)
                num = key;
        }
        return num;
    }