Generate Every Uppercase and Lowercase Variant of a Handle

Last updated: November 29, 2026

Quick Overview

Given a handle made of letters and digits, return every string obtainable by independently changing each letter to uppercase or lowercase. Digits stay as they are.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a handle made of letters and digits, return every string obtainable by independently changing each letter to uppercase or lowercase. Digits stay as they are.

Instagram impersonation checks compare new handles against case variants of protected ones, which makes this a natural backtracking warm-up. Meta interviewers check the choose, explore, unchoose pattern and that you can state the output-sensitive complexity.

What the Interviewer Expects
  • Identify the binary choice at each letter
  • Implement choose, recurse, undo on a mutable buffer
  • Skip branching on digits
  • State complexity as O(2^L * n) for L letters
  • Mention the iterative doubling alternative
Key Topics to Cover
Backtracking
Recursion
Strings
Enumeration
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you do it iteratively without recursion?
  • How would you count variants without generating them?
  • How would you also treat lookalike characters such as 0 and o as variants?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: string of letters and digits, length up to 12.
  • Output: every case variant, any order, no duplicates.
  • Digits are never changed....
High-Level Design

Walk the string left to right. At each index, first recurse without changing the character. If the character is a letter, flip its case, recurse again, then flip it back so the buffer is clean for the...


Submit Your Answer
Markdown supported