Created
February 19, 2020 22:01
-
-
Save ayyucedemirbas/d12e786c4092ef93bb31ee6d03882f55 to your computer and use it in GitHub Desktop.
Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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