Question bank › Strings
Dsa Strings Hard

Ripple Interleaving

Given two strings A and B, determine if a third string C can be formed by interleaving the characters of A and B such that you never take more than K consecutive characters from the same source string (A or B) at a time. All characters from A and B must be used in their original relative order. Input Format: Line 1: String A Line 2: String B Line 3: String C Line 4: Integer K Output Format: Print 'TRUE' if C can be formed under the constraint, otherwise 'FALSE'. Example: Input: aaa bbb aababb 2 Output: TRUE Explanation: We take 2 'a's, 1 'b', 1 'a', then 2 'b's. No more than 2 consecutive from either.

Key concepts

dynamic programmingstringsstate-machine

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.