Skip to content

Instantly share code, notes, and snippets.

@ayyucedemirbas
Created February 19, 2020 22:01
Show Gist options
  • Save ayyucedemirbas/d12e786c4092ef93bb31ee6d03882f55 to your computer and use it in GitHub Desktop.
Save ayyucedemirbas/d12e786c4092ef93bb31ee6d03882f55 to your computer and use it in GitHub Desktop.
Solution
package singleNumber;
import java.util.*;
public class SingleNumber {
public static void main(String[] args) {
int arr[]= {4,5,6,5,6,4,7};
HashMap<Integer, Integer> h = new HashMap<>();
for (int i=0; i<arr.length;i++) {
if (h.containsKey(arr[i])==false) {
h.put(arr[i], 0);
}
else {
h.remove(arr[i]);
}
}
System.out.println(h.keySet().iterator().next());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment