今際の国の呵呵君
Sunday, January 11, 2015
[LeetCode]Rotate List
先算出list的长度len,并且处理k,因为k有可能大于len。之后找到倒数第k + 1个节点,双指针即可。之后再重新连起来即可。时间复杂度O(N),常数空间。代码如下:
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment