Leetcode Problem 784. Letter Case Permutation

784. Letter Case Permutation

Leetcode Solutions

Approach #: Recursion

  1. Define a recursive function that takes the current index and the current permutation of the string.
  2. If the current index is equal to the length of the string, add the current permutation to the result list and return.
  3. If the current character is a digit, add it to the current permutation and recursively call the function with the next index.
  4. If the current character is a letter, create two branches of recursion: one with the lowercase letter and one with the uppercase letter, and increment the index for the next recursive call.
  5. Continue this process until all characters are processed.
UML Thumbnail

Approach #: Binary Mask

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...