Reported August 2026
Quincetwo pointers

Check a Repeated String as a Subsequence

Reported by candidates from Quince's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Quince OA. Under 2s to a working solution.
Founder's read

The edge case that breaks a naive solution here is size. Quince reported this OA in August 2026, and it looks like a plain subsequence check until you read the constraints. str2 can be 100000 characters and k can be 100000, so the repeated string could hit ten billion characters. Build it and you're dead. This is a string problem with a two-pointer core, and the trick is never materializing the repeated string. If you blank on the counting logic during the live assessment, StealthCoder runs invisibly as a safety net and hands you the approach in real time.

The problem

Given two nonempty strings str1 and str2 and a positive integer k, consider the string formed by concatenating str2 with itself exactly k times.
You may delete any characters from str1 without changing the relative order of the remaining characters.
Return true if the repeated string is a subsequence of str1. Otherwise, return false.

Function
isRepeatedSubsequence(str1: String, str2: String, k: int) → boolean

Examples
Example 1
str1 = "abcabcabc"
str2 = "abc"
k = 2
return = true
The first six characters of str1 form abcabc, which is str2 repeated twice.
Example 2
str1 = "abacb"
str2 = "abc"
k = 2
return = false
The required repeated string has six characters, but str1 has only five characters, so it cannot be a subsequence.
Example 3
str1 = "axbyacbz"
str2 = "ab"
k = 2
return = true
Keeping the characters at positions 0, 2, 4, and 6 produces abab.

Constraints
1 <= str1.length, str2.length <= 100000
1 <= k <= 100000
str1 and str2 contain only lowercase English letters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Walk str1 once with a pointer j into str2 and a counter of completed copies. For each character in str1, if it equals str2[j], advance j. When j hits the length of str2, reset j to 0 and increment the counter. Return true the moment the counter reaches k. That's O(n) time and O(1) space, and you never build the repeated string. The pitfalls: building str2 * k causes memory blowup or a timeout. Another is forgetting the quick reject. If len(str2) * k exceeds len(str1), return false immediately, which Example 2 shows. Use a 64-bit integer for that product in languages where overflow matters, since 100000 * 100000 overflows 32 bits. If the loop logic slips under pressure, StealthCoder is the hedge on the live OA. It reads the problem and gives you the single-pass version.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Check a Repeated String as a Subsequence cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Quince's OA.

Quince reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Check a Repeated String as a Subsequence FAQ

What's the trick in the Quince repeated subsequence problem?+

Don't build the repeated string. Scan str1 once, match characters against str2 with a pointer, and count each time you finish a full copy. Stop as soon as the count reaches k. It's a greedy two-pointer pass, linear in the length of str1.

How hard is this problem really?+

Easy to medium. The subsequence idea is standard. The difficulty is noticing that the repeated string can be astronomically large and designing around it. If you know the greedy matching pattern, you can finish it in a few minutes.

What edge cases should I test before submitting?+

Test k = 1, str2 longer than str1, and len(str2) * k exceeding len(str1), which should return false early. Also test max-size inputs to confirm there's no overflow or string building. Single-character strings are worth a quick check too.

Is greedy matching actually correct for subsequences?+

Yes. Matching each needed character at its earliest available position in str1 never hurts, because it leaves the most remaining characters for later matches. Taking a later occurrence can't help, so the single left-to-right pass is both simple and optimal.

How do I prepare for this in 48 hours?+

Practice the basic is-subsequence two-pointer loop until it's automatic. Then add the wraparound: reset the pattern pointer and bump a counter. Write it once in your language, run the three examples, and check the overflow guard on the length product.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Quince.

OA at Quince?
Invisible during screen share
Get it