Letter Case Permutation
Problem Statement
You get a string s made of letters and digits. Every letter can be changed to lower case or upper case on its own. Digits never change.
Return every string you can make this way. The answer can come back in any order.
A string s of lowercase letters, uppercase letters and digits. It has between 1 and 12 characters.
A list of every string you can make by choosing the case of each letter.
There are two letters, a and b. Each one has two versions, so 2 × 2 = 4 strings. The digits 1 and 2 stay the same.
The only letter is z, which can be z or Z. The digits 3 and 4 never change.
- • 1 ≤ s.length ≤ 12
- • s consists only of lowercase English letters, uppercase English letters and digits.
Pattern Recognition Clues
Recognising these key signals in the problem description immediately identifies the pattern:
Approach Complexity Ladder
Loop over the 2^L masks; each bit picks the case of one letter; rebuild each string
Walk the string once; split only at letters into lower and upper; digits pass through
Count the L letters. Loop over every mask from 0 to 2^L − 1. Bit j of the mask decides the case of the j-th letter. For each mask, rebuild the whole string from scratch.
Recognition rule for this sub-pattern:
Unlock Complete Visual Walkthrough & Optimal C++
The interactive animated dry-run player, optimized C++ implementation, state invariant derivations, and edge-case breakdown for this question are part of Brute2Best Pro. The anchor question of every sub-pattern is completely free.
First anchor question per pattern, Part 1 LLD & Module 1 C++ basics are 100% Free forever.
How this concept connects to System Design & C++ Systems
Top engineering interviews test whether you understand how algorithms like Backtracking translate into production architectures and low-level memory mechanics.
Foundations: Object-Oriented Principles in C++23
Class invariants, pure virtual interfaces, and RAII smart pointers.
Food Delivery System (Zomato Architecture)
Real-world machine coding application of algorithms and design patterns.
Pointers vs References Deep Dive
Pointer arithmetic and memory layout under the hood.
Virtual Method Table (vtable) & Memory Layout
Polymorphism, vptr overhead, and multiple inheritance in memory.