@adrrrrrrrian no need to check if dummy1.next == null, 'cause if all nodes's values are greater or equal to x, curr1 will always equals dummy1. This line curr1.next = dummy2.next will result in dummy1 directly pointing to dummy2.next;
After you do l1.next = h2.next, 1 will connect to 2, but in the original list you don't cut off the end of 2, so 2 is still connected to 1, so there will be a loop. If you set l2.next = None, then the final list will ony be 1->2. You can use a pen to figure it out.
you should partition the list but you should not change the order in each partition. In the first example:
1, 2, 2 are smaller than 3 and 4,3,5 are greater or equal than 3 but notice that their order is same is in the original list.
In the second example, there is not node less than 1 and 2,1 are greater or equal to 1 with same order as original list.