Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL. Hide Tags Linked List Two Pointers 这题有点难理解,k 的意思是链表右起第k 个,k 大于…
Rotate List Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL. SOLUTION 1: 重点就是,要先变成循环链表,end.next = head;再执行ListNode he…
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example,Given {1,2,3,4}, reorder it to {1,4,2,3}. Hide Tags Linked List 这题如果使用额外空间,挺容易实现的,确定了中间…