Solution Count The Repetitions
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n\n    /**\n     * @param String $s1\n     * @param Integer $n1\n     * @param String $s2\n     * @param Integer $n2\n     * @return Integer\n     */\n    function getMaxRepetitions($s1, $n1, $s2, $n2) {\n        $l1 = strlen($s1);\n        $l2 = strlen($s2);\n        $next = array_fill(0, $l2 + 1, 0);\n        $count = array_fill(0, $l2 + 1, 0);\n        $cnt = 0;\n        $p = 0;\n        for ($i = 0; $i < $n1; $i++) {\n            for ($j = 0; $j < $l1; $j++) {\n                if ($s1[$j] === $s2[$p]) {\n                    $p++;\n                }\n                if ($p === $l2) {\n                    $cnt++;\n                    $p = 0;\n                }\n            }\n            $count[$i] = $cnt;\n            $next[$i] = $p;\n            for ($j = 0; $j < $i; $j++) {\n                if ($next[$j] === $p) {\n                    $prev_count = $count[$j];\n                    $pattern_count = ($count[$i] - $count[$j]) * floor(($n1 - $j - 1) / ($i - $j));\n                    $remain_count = $count[$j + ($n1 - $j - 1) % ($i - $j)] - $count[$j];\n                    return floor(($prev_count + $pattern_count + $remain_count) / $n2);\n                }\n            }\n        }\n        return floor($count[$n1 - 1] / $n2);\n    }\n}\n\n```
['PHP']