Trains the technique from
LeetCode 784Letter Case PermutationThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A warehouse scanner reads part codes made of English letters and digits, and it ignores letter case, so the same part code can be keyed in more than one way.
Return every spelling of code that can be produced by choosing, independently for each letter, whether that letter is written in uppercase or in lowercase. Digits are copied over unchanged.
The spellings may be returned in any order, and each distinct spelling must appear exactly once.
Example 1
Two letters each have two cases, so four spellings come out, and the digit 4 stays put in every one of them.
Example 2
There is no letter to choose a case for, so the code has exactly one spelling, itself.
Example 3
Each of the two letters is written either way, whatever case it arrived in, giving four spellings.
The values you return may be in any order.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def code_spellings(code: str) -> list[str]:public List<String> codeSpellings(String code)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.