fix: further+ simplify

This commit is contained in:
Lam Haoyin 2022-04-07 02:06:59 +08:00
parent 7e99751414
commit ba5dd1c5f2
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
1 changed files with 3 additions and 3 deletions

View File

@ -2,10 +2,10 @@
class Solution {
public:
static bool rotateString(const std::string& s, const std::string& goal) {
static bool rotateString(const std::string& s, const std::string& g) {
const std::size_t n = s.length();
for (std::size_t np = goal.find(s[0], 0); np != std::string::npos; np = goal.find(s[0], np + 1))
if (goal.substr(0, np) == s.substr(n - np) && goal.substr(np) == s.substr(0, n - np))
for (std::size_t np = g.find(s[0], 0); np != std::string::npos; np = g.find(s[0], np + 1))
if (g.substr(np) + g.substr(0, np) == s)
return true;
return false;
}