Partition Linked List around a Value X

How do you partition a list around a value x, such that all nodes less than x come before all nodes greater than or equal to x?

Well, there are some solutions possible. The solution, I came up with, is a bit convoluted but let me tell the idea behind it. You want to track the following:

Now that we have this out of the way, let’s look at the code:


As usual the code is available here:

comments powered by Disqus