86
class Solution { public ListNode partition(ListNode head, int x) { ListNode lowheader=new ListNode(0); ListNode low=lowheader; ListNode highheader=new ListNode(0); ListNode high=highheader; while(head!=null){ if(head.val<x){ low.next=head; head=head.next; low=low.next; low.next=null; }else{ high.next=head; head=head.next; high=high.next; high.next=null; } } low.next=highheader.next; return lowheader.next; } }
原文:https://www.cnblogs.com/yttas/p/10433674.html