1 //按照剑指offer书上的方法,两次翻转字符串。 2 class Solution { 3 public: 4 string LeftRotateString(string str, int n) { 5 reverse(str.begin(), str.end()); 6 reverse(str.begin(), str.begin() + str.size() - n); 7 reverse(str.begin() + str.size() - n, str.end()); 8 return str; 9 } 10 };