We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 040eba2 commit 91a75d4Copy full SHA for 91a75d4
src/leetcode/SingleNumber.java
@@ -10,17 +10,17 @@ public static void main(String[] args){
10
}
11
12
public int singleNumber(int[] nums) {
13
- Map<Integer,Integer> map = new HashMap<>();
14
- for(int i: nums){
15
- if(map.containsKey(i))
16
- map.put(i, map.get(i)+1);
17
- else
18
- map.put(i, 1);
19
- }
20
- for(Map.Entry e: map.entrySet()){
21
- if((int)e.getValue()==1)
22
- return (int)e.getKey();
23
24
- return 0;
25
+ Map<Integer,Integer> map = new HashMap<>();
+ for(int i: nums){
+ if(map.containsKey(i))
+ map.put(i, map.get(i)+1);
+ else
+ map.put(i, 1);
+ }
+ for(Map.Entry e: map.entrySet()){
+ if((int)e.getValue()==1)
+ return (int)e.getKey();
+ return 0;
26
0 commit comments