Problem
Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.
Return a list of all possible strings we could create. You can return the output in any order.
Example 1:
1 | Input: S = "a1b2" |
Example 2:
1 | Input: S = "3z4" |
Example 3:
1 | Input: S = "12345" |
Example 4:
1 | Input: S = "0" |
Constraints:
S
will be a string with length between1
and12
.S
will consist only of letters or digits.
Analysis
题目给出了一个包含数字和字母的字符串,我们可以把任何一个字母都转为小写或者大写,要求我们返回所有的组合。思路还是很简单的,就按照题目的要求来。首先我们维护一个result
的字符串数组,如果遇上数字直接加到每一个字符串的后面;如果遇上字符,分别把大小写加到每一个字符串后面。
Solution
无
Code
1 | class Solution { |
Summary
这道题目的分享到这里,谢谢您的支持!