Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contains-duplicate/pmjuu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
return len(nums) != len(set(nums))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 python은 이렇게 set 자료구조를 간편하게 쓸 수 있어 너무 깔끔하게 처리되는군요.

21 changes: 21 additions & 0 deletions valid-palindrome/pmjuu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution:
def isPalindrome(self, s: str) -> bool:
# two pointer
left, right = 0, len(s) - 1

while left < right:
# compare only alphanumeric characters
while left < right and not s[left].isalnum():
left += 1
while left < right and not s[right].isalnum():
right -= 1

# compare with lowercase
if s[left].lower() != s[right].lower():
return False

# move pointers
left += 1
right -= 1

return True
Loading