commit e5b048bd4ec4008a684679475dd8c16edc323e42 parent a637c3e07cc050114768c31ba1710270071ec2be Author: Dimitrije Dobrota <mail@dimitrijedobrota.com> Date: Mon, 21 Aug 2023 19:07:32 +0200 Daily Problem Diffstat:
A | Problems/0459.cpp | | | 14 | ++++++++++++++ |
M | README.md | | | 1 | + |
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/Problems/0459.cpp b/Problems/0459.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + bool repeatedSubstringPattern(const string &s) { + string made; + for (int i = 1; i <= s.size() / 2; i++) { + if (s.size() % i) continue; + const string pref = s.substr(0, i); + for (int j = 0; j < s.size() / i; j++) made += pref; + if (made == s) return true; + made.clear(); + } + return false; + } +}; diff --git a/README.md b/README.md @@ -287,6 +287,7 @@ for solving problems. | 0450 | Medium | [Delete Node in a BST](Problems/0450.cpp) | | 0451 | Medium | [Sort Characters By Frequency](Problems/0451.cpp) | | 0452 | Medium | [Minimum Number of Arrows to Burst Balloons](Problems/0452.cpp) | +| 0459 | Easy | [Repeated Substring Pattern](Problems/0459.cpp) | | 0460 | Hard | [LFU Cache](Problems/0460.cpp) | | 0472 | Hard | [Concatenated Words](Problems/0472.cpp) | | 0485 | Easy | [Max Consecutive Ones](Problems/0485.cpp) |