LeetCode p61 Rotate List 题解
1.题目:
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.
 
题意:
输入一个链表转置它末尾的K个数。
2.解题思路:
见代码,输入的K可能会超过链表长度。
3.代码
1  | 
  | 
很高兴遇见你~
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.
 
题意:
输入一个链表转置它末尾的K个数。
见代码,输入的K可能会超过链表长度。
1  | 
  |