Ai
1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
letter-case-permutation.py 557 Bytes
Copy Edit Raw Blame History
Allen Liu authored 2018-10-12 01:33 +08:00 . remove sensitive question description
# Time: O(n * 2^n)
# Space: O(n * 2^n)
class Solution(object):
def letterCasePermutation(self, S):
"""
:type S: str
:rtype: List[str]
"""
result = [[]]
for c in S:
if c.isalpha():
for i in xrange(len(result)):
result.append(result[i][:])
result[i].append(c.lower())
result[-1].append(c.upper())
else:
for s in result:
s.append(c)
return map("".join, result)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

Search