Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- 우분투
- SW Expert Academy
- dacon
- 백준
- Real or Not? NLP with Disaster Tweets
- leetcode
- 편스토랑 우승상품
- 캐치카페
- ChatGPT
- 더현대서울 맛집
- Git
- 맥북
- gs25
- 금융문자분석경진대회
- AI 경진대회
- 데이콘
- 편스토랑
- ubuntu
- programmers
- github
- hackerrank
- Kaggle
- 코로나19
- Baekjoon
- 프로그래머스 파이썬
- Docker
- PYTHON
- 자연어처리
- 파이썬
- 프로그래머스
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 784. Letter Case Permutation (Python) 본문
728x90
반응형
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:
Input: S = "a1b2"
Output: ["a1b2","a1B2","A1b2","A1B2"]
Example 2:
Input: S = "3z4"
Output: ["3z4","3Z4"]
Example 3:
Input: S = "12345"
Output: ["12345"]
Example 4:
Input: S = "0"
Output: ["0"]
Constraints:
- S will be a string with length between 1 and 12.
- S will consist only of letters or digits.
Solution
class Solution:
def letterCasePermutation(self, S: str) -> List[str]:
answer = [""]
for i in range(len(S)):
temp = []
for j in range(len(answer)):
if S[i].isalpha():
temp.append(answer[j] + S[i].lower())
temp.append(answer[j] + S[i].upper())
else:
temp.append(answer[j] + S[i])
answer = temp
return answer
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 1486. XOR Operation in an Array (Python) (0) | 2021.01.28 |
---|---|
[leetCode] 476. Number Complement (Python) (0) | 2021.01.27 |
[leetCode] 367. Valid Perfect Square (Python) (0) | 2021.01.25 |
[leetCode] 804. Unique Morse Code Words (Python) (0) | 2021.01.24 |
[leetCode] 1636. Sort Array by Increasing Frequency (Python) (0) | 2021.01.23 |
Comments