Skip to content

Commit 19a0c03

Browse files
Create 300.py
1 parent da6e627 commit 19a0c03

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

001-500/300.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def lengthOfLIS(self, nums: List[int]) -> int:
3+
packs = []
4+
5+
for num in nums:
6+
if not packs or num > packs[-1]:
7+
packs.append(num)
8+
else:
9+
i = bisect.bisect_left(packs, num)
10+
packs[i] = num
11+
12+
return len(packs)
13+

0 commit comments

Comments
 (0)