# 796-Rotate String ###### tags: `Easy` ## Question https://leetcode.com/problems/rotate-string/ ## Key 1. swap each char in all possibility 2. keep saving the first char and push back to the last char ## Reference ## Solution ```cpp= class Solution { public: bool rotateString(string A, string B) { if(A == B) return true; int count = A.size() + 1; while(--count) { if(A == B) return true; const auto first = A[0]; A.erase(A.begin()); A.push_back(first); } return false; } }; ```