Question bank › Strings
Dsa Strings Medium

The Interleaved Case-Switcher

Two messages are interleaved in one string. Message A consists of lowercase letters, and Message B consists of uppercase letters. However, a special character '#' acts as a 'switch'—it assigns the next character to the *other* person's message, regardless of its case. After that one character, the rules revert to case-based assignment. Reconstruct both messages. Example: Input: aB#c#D Output: ac BD (Explanation: 'a' is lower (A). 'B' is upper (B). '#' switches next char 'c' to B. '#' switches next char 'D' to A.)

Key concepts

state-machinestring-manipulation

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.