观察字符串前后变化即可
class Solution {
public:
string LeftRotateString(string str, int n) {
if (str.empty() || n % str.size() == 0) {
return str;
}
n = n % str.size();
std::reverse(str.begin(), str.begin() + n);
std::reverse(str.begin() + n, str.end());
std::reverse(str.begin(), str.end());
return str;
}
};