Rotate String
https://www.lintcode.com/problem/rotate-string/description
Description
Given a string and an offset, rotate string by offset. (rotate from left to right)
Have you met this question in a real interview?
Yes
Problem Correction
Example
Given"abcdefg".
offset=0 => "abcdefg"
offset=1 => "gabcdef"
offset=2 => "fgabcde"
offset=3 => "efgabcd"Challenge
Rotate in-place with O(1) extra memory.
Analysis
Solution
三步翻转法 O(n) time, O(1) sapce
Last updated
Was this helpful?