Skip to content

Commit

Permalink
Merge pull request #1021 from Soohyeun/main
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Sep 30, 2024
2 parents deadbf0 + f094593 commit 78a75d2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Soohyeun/2024-09-23-IsAnagram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from collections import defaultdict


class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if len(s) != len(t):
return False

seen = defaultdict(int)
for i in range(len(s)):
seen[s[i]] += 1
seen[t[i]] -= 1
if seen[s[i]] == 0:
del seen[s[i]]
if seen[t[i]] == 0:
del seen[t[i]]

return True if not seen else False
9 changes: 9 additions & 0 deletions Soohyeun/2024-09-23-TwoIntegerSum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
seen = dict()
for index, num in enumerate(nums):
rest = target - num
if rest in seen.keys():
return [seen[rest], index]
seen[num] = index
return -1
5 changes: 5 additions & 0 deletions Soohyeun/2024-09-26-DuplicateInteger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Solution:
def hasDuplicate(self, nums: List[int]) -> bool:
set_num = set(nums)

return False if len(set_num) == len(nums) else True

0 comments on commit 78a75d2

Please sign in to comment.