From ba5dd1c5f2cb099b28f25615eb9b9887c7a413cf Mon Sep 17 00:00:00 2001 From: Lam Haoyin Date: Thu, 7 Apr 2022 02:06:59 +0800 Subject: [PATCH] fix: further+ simplify --- cpp/2204/220407-CN.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/2204/220407-CN.cpp b/cpp/2204/220407-CN.cpp index 5ac30e1..78a6f1b 100644 --- a/cpp/2204/220407-CN.cpp +++ b/cpp/2204/220407-CN.cpp @@ -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; }