Title: Assembly language there is a left cyclic shift instruction is called (the ROL), and now there is a simple task, this instruction is simulated by the string operation result. For a given character sequence S, you put its left circle after K-bit serial output. For example, the character sequence S = "abcXYZdef", rotated left required output result after three, i.e. "XYZdefabc". Is not it simple? OK, get it!
Ideas: the original string of the original string in the back ground again, and then starting from the n-th bit output to intercept the string length of the original string.
class Solution {
public:
string LeftRotateString(string str, int n) {
int length =str.size();
if(length==0) return {};
string s = str+str;
n %=length;
return s.substr(n,length);
}
};