标签:
public ListNode partition(ListNode head, int x) { if(head == null) return null; ListNode helper = new ListNode(0); helper.next = head; ListNode walker = helper; ListNode runner = helper; while(runner.next!=null) { if(runner.next.val<x) { if(walker!=runner) { ListNode next = runner.next.next; runner.next.next = walker.next; walker.next = runner.next; runner.next = next; } else runner = runner.next; walker = walker.next; } else { runner = runner.next; } } return helper.next; }这道题思路比較清晰,只是还是有点细节的,第一次写可能不easy全然写对,能够练习练习。
标签:
原文地址:http://www.cnblogs.com/hrhguanli/p/4548391.html