Question is: Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x.

I was given this answer:

```
public Node partition(Node head, int x) {
    Node firstHead = null;
    Node secondHead = null;
    Node n = head;

    if (head == null) {
        return null;
    }

    while (n != null) {
        Node next = n.next;

        if (n.data < x) {
            n.next = firstHead; *
            firstHead = n;
        }
        else {
            n.next = secondHead;
            secondHead = n;
        }

        n = next; **
    } 

    if (firstHead == null) {
        return secondHead;
    }
    else {
        n = firstHead;

        while (n.next != null) {
            n = n.next;
        }

        n.next = secondHead;

        return firstHead;
    }
}

```

For example, if the list is 3 7 9 1 4 8 2 3 and you are to partition at x=4 then inside the first while loop second element (7) would be set to null (where there is a star in the code) then n will be set 7 again (where there is two stars). I am not quite sure how this works? Is another node in the LinkedList created and the null is pushed back? Sorry for any trouble