Skip to content

Commit 4604092

Browse files
committed
Added Partition Linked list - Medium
1 parent c777dfb commit 4604092

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

CrackingTheCodingInterview/LinkedListSolutions/partition_linked_list.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public ListNode partition(ListNode node, int x) {
1414
while (node != null) {
1515
// Let us insert into the before and after lists
1616
ListNode next = node.next;
17-
node.next = null; // ??
17+
node.next = null; // Cut off the connection to the other nodes
1818
if (node.val < x) {
1919
// Insert into before list
2020
if (beforeStart == null) {
@@ -34,7 +34,7 @@ public ListNode partition(ListNode node, int x) {
3434
afterEnd = node;
3535
}
3636
}
37-
node = node.next;
37+
node = next;
3838
}
3939
// Now we check if our before list == null, meaning we only
4040
// Have nodes that are greater so we return after

0 commit comments

Comments
 (0)