Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /