Sword Finger Offer Question 43
The topic is as follows
Idea and code
The cycle moves to the left, and it feels like I suddenly returned to the time of learning the principles of microcomputers.
Hey, I'm so nostalgic!
Just do it directly and you're done, too many ideas!
Two queues, or vector deletion and addition operations are also fine!
Here directly use the substr of c++ to complete it! Find the location directly, one size fits all, so cool!
class Solution {
public:
string LeftRotateString(string str, int n) {
int size=str.length();
if(size==0) return "";
else n%=size;
string s1=str.substr(0,n);
string s2=str.substr(n,size-n);
return s2+s1;
}
};