[leetcode] Rotate List
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. 陷阱挺多,需要小心。 1. 如果链表为空或k==0,return head; 2. 如果k>链表长度count, k = k % count; /** * Definition for singly-linked list. * struct ListNode { * […]