You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -208,7 +208,7 @@ Your ideas/fixes/algorithms are more than welcome!
208
208
|396|[Rotate Function](https://leetcode.com/problems/rotate-function/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_396.java)| O(n^2) could be optimized to O(n) | O(1) | Easy|
209
209
|393|[UTF-8 Validation](https://leetcode.com/problems/utf-8-validation/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_393.java)| O(?)|O(?) | Medium| Bit Manipulation
|387|[First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_387.java)| O(n)|O(n) | Easy| HashMap
Copy file name to clipboardExpand all lines: src/main/java/com/fishercoder/solutions/_390.java
+11-9
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,13 @@
3
3
importjava.util.ArrayList;
4
4
importjava.util.List;
5
5
6
-
/**There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.
7
-
8
-
Repeat the previous step again, but this time from right to left, remove the right most number and every other number from the remaining numbers.
9
-
10
-
We keep repeating the steps again, alternating left to right and right to left, until a single number remains.
11
-
12
-
Find the last number that remains starting with a list of length n.
6
+
/**There is a list of sorted integers from 1 to n.
7
+
* Starting from left to right,
8
+
* remove the first number and every other number afterward until you reach the end of the list.
9
+
* Repeat the previous step again, but this time from right to left,
10
+
* remove the right most number and every other number from the remaining numbers.
11
+
* We keep repeating the steps again, alternating left to right and right to left, until a single number remains.
12
+
* Find the last number that remains starting with a list of length n.
13
13
14
14
Example:
15
15
@@ -21,8 +21,10 @@
21
21
6
22
22
23
23
Output:
24
-
6*/
25
-
publicclassEliminationGame {
24
+
6
25
+
26
+
*/
27
+
publicclass_390 {
26
28
27
29
//then I turned to Discuss and found this post: https://discuss.leetcode.com/topic/55870/share-my-solutions-for-contest-2
28
30
//instead of literally removing half of the elements in each scan, this solution is just moving the pointer to point to next start position
0 commit comments