Enumerate Every Independent Letter-Case Choice

Quick Overview

Enumerate Every Independent Letter-Case Choice. For each English letter in s, independently choose uppercase or lowercase; digits stay unchanged.

Enumerate Every Independent Letter-Case Choice

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem For each English letter in s, independently choose uppercase or lowercase; digits stay unchanged. Return every distinct resulting string in any order. ```cpp class Solution { public: vector<string> letterCasePermutation(string s); }; ``` ### Examples **Example 1:** ```text s = "B7" One valid output: ["b7","B7"] Explanation: The one letter has two choices. ``` **Example 2:** ```text s = "42" Output: ["42"] Explanation: Digits offer no case choice. ``` ### Constraints - String length ranges from 1 through 12. - Characters are English letters of either case or decimal digits. ### Contract considerations Preserve digits and the full list of all case assignments. ```hint Read the boundary condition How many independent choices does a letter introduce? ``` ### What a Strong Answer Covers Preserve digits and the full list of all case assignments. ### Follow-up Questions Optional practice extension: How could results be yielded one at a time when storing the whole list is undesirable?

Overview: Enumerate Every Independent Letter-Case Choice. For each English letter in s, independently choose uppercase or lowercase; digits stay unchanged.

Google logo
Google
Source window: 0–3 months · as of Oct 21, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

For each English letter in s, independently choose uppercase or lowercase; digits stay unchanged. Return every distinct resulting string in any order.

class Solution {
public:
    vector<string> letterCasePermutation(string s);
};

Examples

Example 1:

s = "B7"
One valid output: ["b7","B7"]
Explanation: The one letter has two choices.

Example 2:

s = "42"
Output: ["42"]
Explanation: Digits offer no case choice.

Constraints

  • String length ranges from 1 through 12.
  • Characters are English letters of either case or decimal digits.

Contract considerations

Preserve digits and the full list of all case assignments.

What a Strong Answer Covers Guidance

Preserve digits and the full list of all case assignments.

Follow-up Questions Guidance

Optional practice extension: How could results be yielded one at a time when storing the whole list is undesirable?