[leetcode] 一些会的

链表:

61. 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.

cornercase是k大于n的时候,k = k % n;

先数出链表长度,再数出后半条链表的头的index,然后拿来。

posted @ 2016-12-29 05:13  Gryffin  阅读(118)  评论(0编辑  收藏  举报