Skip to content

Commit e038049

Browse files
edit 260
1 parent 65603cb commit e038049

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ Your ideas/fixes/algorithms are more than welcome!
319319
|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_264.java)| O(n)|O(n) | Medium| DP
320320
|263|[Ugly Number](https://leetcode.com/problems/ugly-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_263.java)| O(n)|O(1) | Easy|
321321
|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree/)|[Solution](../master/src/main/java/com/fishercoder/solutions/GraphValidTree.java)| O(V+E)|O(V+E) | Medium|
322+
|260|[Single Number III](https://leetcode.com/problems/single-number-iii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_260.java)| O(n)|O(n) | Medium|
322323
|259|[3Sum Smaller](https://leetcode.com/problems/3sum-smaller/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_259.java)| O(n^2)|O(1) | Medium|
323324
|258|[Add Digits](https://leetcode.com/problems/add-digits/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_258.java)| O(1)|O(1) | Easy|
324325
|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_257.java) | O(n*h) | O(h) | DFS/Recursion

src/main/java/com/fishercoder/solutions/SingleNumberIII.java renamed to src/main/java/com/fishercoder/solutions/_260.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6-
/**260. Single Number III QuestionEditorial Solution My Submissions
7-
Total Accepted: 42536
8-
Total Submissions: 92175
9-
Difficulty: Medium
6+
/**260. Single Number III
107
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.
118
129
For example:
@@ -17,17 +14,16 @@
1714
The order of the result is not important. So in the above example, [5, 3] is also correct.
1815
Your algorithm should run in linear runtime complexity. Could you implement it using only constant space complexity?
1916
*/
20-
public class SingleNumberIII {
21-
// TODO: study its bit manipulation way, this is a MUST!
22-
23-
17+
18+
public class _260 {
19+
2420
//Approach 1: normal hashmap
2521
public int[] singleNumber(int[] nums) {
2622
Map<Integer, Integer> map = new HashMap();
2723
for(int i : nums){
2824
map.put(i, map.getOrDefault(i, 0)+1);
2925
}
30-
26+
3127
int[] res = new int[2];
3228
int index = 0;
3329
for(int key : map.keySet()){
@@ -36,4 +32,5 @@ public int[] singleNumber(int[] nums) {
3632
}
3733
return res;
3834
}
35+
// TODO: study its bit manipulation way, this is a MUST!
3936
}

0 commit comments

Comments
 (0)