We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4942fc3 commit 688c7c4Copy full SHA for 688c7c4
2 files changed
house-robber/YOOHYOJEONG.py
@@ -0,0 +1,15 @@
1
+# https://leetcode.com/problems/house-robber/
2
+
3
+class Solution(object):
4
+ def rob(self, nums):
5
6
+ prev = 0
7
+ prev_2 = 0
8
9
+ for num in nums:
10
+ cur = max(prev, prev_2 + num)
11
12
+ prev_2 = prev
13
+ prev = cur
14
15
+ return prev
longest-consecutive-sequence/YOOHYOJEONG.py
@@ -0,0 +1,21 @@
+# https://leetcode.com/problems/longest-consecutive-sequence/
+ def longestConsecutive(self, nums):
+ nums_set = set(nums)
+ lens = 0
+ for n in nums_set:
+ if n-1 not in nums_set:
+ cur = n
+ lenth = 1
+ while cur+1 in nums_set:
16
+ cur += 1
17
+ lenth += 1
18
19
+ lens = max(lens, lenth)
20
21
+ return lens
0 commit comments