File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
src/main/java/com/fishercoder/solutions/secondthousand Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,9 @@ public int findTheWinner(int n, int k) {
24
24
25
25
public static class Solution2 {
26
26
/**
27
- * My completely original solution: use a double linked list to keep moving people from
28
- * the tail of the queue to the head of the queue until there's only one person in the queue who is the winner.
27
+ * My completely original solution: use a double linked list to keep moving (k - 1) people from
28
+ * the tail of the queue to the head of the queue, and then remove the kth person,
29
+ * until there's only one person in the queue who is the winner.
29
30
*/
30
31
public int findTheWinner (int n , int k ) {
31
32
Deque <Integer > doublyLinkedList = new LinkedList <>();
You can’t perform that action at this time.
0 commit comments