mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			9 lines
		
	
	
		
			608 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			9 lines
		
	
	
		
			608 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>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. If x is contained within the list, the values of x only need to be after the elements less than x (see below). The partition element x can appear anywhere in the "right partition"; it does not need to appear between the left and right partitions.</p>
 | 
						|
 | 
						|
<p><strong>Example:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> head = 3->5->8->5->10->2->1, <em>x</em> = 5
 | 
						|
<strong>Output:</strong> 3->1->2->10->5->5->8
 | 
						|
</pre>
 |