LintCode(easy)旋转字符串(!!!我有史以来解决的问题最快的一次,心酸流泪)

2019-07-14 11:52发布

class Solution { public: /** * @param str: a string * @param offset: an integer * @return: nothing */ void rotateString(string &str,int offset){ //wirte your code here if(str.size()>0){ offset=offset%str.size(); string a = str.substr(str.size() - offset, offset); str.erase(str.size() - offset, offset); str = a + str; } else{} } };