Skip to content

Commit d62d45f

Browse files
committed
feat: 1주차 easy level 문제 풀이
1 parent d975b97 commit d62d45f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

contains-duplicate/jinah92.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def containsDuplicate(self, nums: List[int]) -> bool:
3+
keys = set()
4+
for num in nums:
5+
if num in keys:
6+
return True
7+
else:
8+
keys.add(num)
9+
10+
return False

valid-palindrome/jinah92.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import re
2+
3+
class Solution:
4+
def isPalindrome(self, s: str) -> bool:
5+
replaced_string = re.sub(r"[^a-zA-Z0-9]", "", s).lower()
6+
7+
if len(replaced_string) == 0:
8+
return True
9+
10+
start, end = 0, len(replaced_string)-1
11+
12+
while start <= len(replaced_string) // 2:
13+
if replaced_string[start] is not replaced_string[end]:
14+
return False
15+
16+
start += 1
17+
end -= 1
18+
19+
return True

0 commit comments

Comments
 (0)