标签:r++ i++ counter java list 排序 int 冒泡排序 nbsp
Sort_List
冒泡排序(超时了)
public ListNode sortList(ListNode head) { if(null == head) return head; int counter = 0; ListNode current = head; while (null != current.next) { current = current.next; counter++; } current = head; int pre; while (counter > 0) { for (int i = 0; i < counter; i++) { if (current.val > current.next.val) { pre = current.val; current.val = current.next.val; current.next.val = pre; } current = current.next; } current = head; counter--; } return head; }
标签:r++ i++ counter java list 排序 int 冒泡排序 nbsp
原文地址:https://www.cnblogs.com/Jomini/p/11735623.html