剑指OFFER----面试题58 - II. 左旋转字符串

链接:https://leetcode-cn.com/problems/zuo-xuan-zhuan-zi-fu-chuan-lcof/

代码

class Solution {
public:
    string reverseLeftWords(string s, int n) {
        reverse(s.begin(), s.end());
        reverse(s.begin(), s.begin() + s.size() - n);
        reverse(s.begin() + s.size() - n, s.end());
        return s;
    }
};
posted @ 2020-03-12 21:00  景云ⁿ  阅读(65)  评论(0编辑  收藏  举报