Search
⌘K

Leetcode 466. Count The Repetitions

Given s1, s2 and repetition counts n1, n2, find the maximum m such that s2 repeated m (i.e., [s2, m]) can be obtained as a subsequence of s1 repeated n1 — equivalently, how many full copies of s2 you can sequentially extract from the concatenated s1's. The core challenge is to handle large n1/n2 (up to 1e6) efficiently by simulating subsequence matching and detecting repeating states/cycles.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.