From 08a8b9a3f62f1f3b17406c22d59eaa6eccbab988 Mon Sep 17 00:00:00 2001 From: 6kitty Date: Tue, 11 Nov 2025 01:34:53 +0900 Subject: [PATCH 1/5] two sum solution --- two-sum/6kitty.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 two-sum/6kitty.py diff --git a/two-sum/6kitty.py b/two-sum/6kitty.py new file mode 100644 index 0000000000..0e3012ea16 --- /dev/null +++ b/two-sum/6kitty.py @@ -0,0 +1,16 @@ +# +# @lc app=leetcode id=1 lang=python3 +# +# [1] Two Sum +# + +# @lc code=start +class Solution: + def twoSum(self, nums: List[int], target: int) -> List[int]: + for i,num in enumerate(nums): + for j in range(i+1,len(nums)): + if num + nums[j] == target: + return [i,j] + +# @lc code=end + From 0d38c78fa0db1c7b0ffb48c4c5da94f3d1d062d1 Mon Sep 17 00:00:00 2001 From: 6kitty Date: Tue, 11 Nov 2025 02:02:45 +0900 Subject: [PATCH 2/5] contains-duplicate solution --- contains-duplicate/6kitty.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 contains-duplicate/6kitty.py diff --git a/contains-duplicate/6kitty.py b/contains-duplicate/6kitty.py new file mode 100644 index 0000000000..a5a33a9986 --- /dev/null +++ b/contains-duplicate/6kitty.py @@ -0,0 +1,20 @@ +# +# @lc app=leetcode id=217 lang=python3 +# +# [217] Contains Duplicate +# + +# @lc code=start +class Solution: + def containsDuplicate(self, nums: List[int]) -> bool: + # list로 하니까 시간 초과 떠서 set으로 변경 + idx=set() + for i in nums: + if i in idx: + return True + idx.add(i) + # null 방지 + return False + +# @lc code=end + From 782fd83821d423c1b193ad3bcc678fb9472479f4 Mon Sep 17 00:00:00 2001 From: 6kitty Date: Wed, 12 Nov 2025 19:13:30 +0900 Subject: [PATCH 3/5] top k frequent elements --- top-k-frequent-elements/6kitty.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 top-k-frequent-elements/6kitty.py diff --git a/top-k-frequent-elements/6kitty.py b/top-k-frequent-elements/6kitty.py new file mode 100644 index 0000000000..583649961f --- /dev/null +++ b/top-k-frequent-elements/6kitty.py @@ -0,0 +1,28 @@ +# +# @lc app=leetcode id=347 lang=python3 +# +# [347] Top K Frequent Elements +# + +# @lc code=start +class Solution: + def topKFrequent(self, nums: List[int], k: int) -> List[int]: + sol = {} + for i in nums: + sol[i] = sol.get(i, 0) + 1 + + sorted_items = sorted(sol.items(), key=lambda x: x[1], reverse=True) + + ssol = [] + for i in range(k): + ssol.append(sorted_items[i][0]) + + return ssol + + + + + + +# @lc code=end + From 4b46c37c4ac8464eb0cb4284acd19fec3662f2bf Mon Sep 17 00:00:00 2001 From: 6kitty Date: Sat, 15 Nov 2025 22:37:33 +0900 Subject: [PATCH 4/5] longest consecutive sequence solution --- longest-consecutive-sequence/6kitty.py | 28 ++++++++++++++++++++++++++ top-k-frequent-elements/6kitty.py | 3 --- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 longest-consecutive-sequence/6kitty.py diff --git a/longest-consecutive-sequence/6kitty.py b/longest-consecutive-sequence/6kitty.py new file mode 100644 index 0000000000..249cfbf91d --- /dev/null +++ b/longest-consecutive-sequence/6kitty.py @@ -0,0 +1,28 @@ +# +# @lc app=leetcode id=128 lang=python3 +# +# [128] Longest Consecutive Sequence +# +from typing import List +# @lc code=start +class Solution: + def longestConsecutive(self, nums: List[int]) -> int: + nums.sort() + long=0 + + leng=1 + for i in range(len(nums)-1): + if nums[i]==nums[i+1]: + continue + if nums[i]+1==nums[i+1]: + leng+=1 + else: + long=max(long,leng) + leng=1 + # 아래를 추가해야 for문 다 돌았을 때 leng이 최고인 경우 반영 + long=max(long,leng) + return long + + +# @lc code=end + diff --git a/top-k-frequent-elements/6kitty.py b/top-k-frequent-elements/6kitty.py index 583649961f..5d9c94f5a2 100644 --- a/top-k-frequent-elements/6kitty.py +++ b/top-k-frequent-elements/6kitty.py @@ -20,9 +20,6 @@ def topKFrequent(self, nums: List[int], k: int) -> List[int]: return ssol - - - # @lc code=end From e1d219d6880f31ca58b40f010e8bb2fb664105a8 Mon Sep 17 00:00:00 2001 From: 6kitty Date: Sat, 15 Nov 2025 23:12:56 +0900 Subject: [PATCH 5/5] house robber solution --- house-robber/6kitty.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 house-robber/6kitty.py diff --git a/house-robber/6kitty.py b/house-robber/6kitty.py new file mode 100644 index 0000000000..8a1b65a470 --- /dev/null +++ b/house-robber/6kitty.py @@ -0,0 +1,17 @@ +# +# @lc app=leetcode id=198 lang=python3 +# +# [198] House Robber +# + +# @lc code=start +class Solution: + def rob(self, nums: List[int]) -> int: + pre=0 + cur=0 + for num in nums: + pre, cur = cur, max(num + pre, cur) + return cur + +# @lc code=end +