Closed ghost closed 9 years ago
You are right! let me do some improvement.
code change : https://github.com/haoel/leetcode/commit/356254b9189311f7bf6216bd002adf36c8988e26
(oops, seems github misses match the code commit message to close the issue.)
Great, more interesting than my two pointers version. :+1:
https://github.com/haoel/leetcode/blob/ad62b9d82e8d72a3923881840b23532216c12982/src/rotateList/rotateList.cpp#L35-L36
Given the length n, you only need to loop about n~2n times if k is much more bigger than n.