rotate string
code
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.empty())
{
return ;
}
int n = (int)str.length();
offset = offset%n;
string shadow;
for(int i = 0; i<n; i++)
{
int j = (n-offset+i)%n;
shadow.push_back(str[j]);
}
str = shadow;
}
};