https://leetcode.com/problems/first-letter-to-appear-twice/description/
First Letter to Appear Twice - LeetCode
First Letter to Appear Twice - Given a string s consisting of lowercase English letters, return the first letter to appear twice. Note: * A letter a appears twice before another letter b if the second occurrence of a is before the second occurrence of b. *
leetcode.com
1
2
3
4
5
6
7
8
|
class Solution:
def repeatedCharacter(self, s: str) -> str:
string_list = []
for i in s:
if i not in string_list:
string_list.append(i)
else:
return i
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2138. Divide a String Into Groups of Size k (0) | 2023.01.12 |
---|---|
leetcode 2180. Count Integers With Even Digit Sum (0) | 2023.01.12 |
leetcode 1768. Merge Strings Alternately (0) | 2023.01.11 |
leetcode 728. Self Dividing Numbers (0) | 2023.01.10 |
leetcode 2427. Number of Common Factors (0) | 2023.01.10 |
댓글