fix: further+ simplify
This commit is contained in:
parent
7e99751414
commit
ba5dd1c5f2
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue