Leetcode 459 Solution

This article provides solution to leetcode question 459 (repeated-substring-pattern)

https://leetcode.com/problems/repeated-substring-pattern

Solution

class Solution {
public:
    bool repeatedSubstringPattern(string str) {
        if (str.size() == 0)
            return false;

        string str2 = str.substr(1, str.size() - 1) + str.substr(0, str.size() - 1);
        return strstr(str2.c_str(), str.c_str());
    }
};