Skip to content

Commit

Permalink
Improve the SolutionShort
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyannn committed May 25, 2022
1 parent 59f81a8 commit 9a19118
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lc_0354_envelopes.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from bisect import bisect_left
from math import inf
from typing import List
import unittest


class SolutionShort:
def maxEnvelopes(self, envelopes: List[List[int]]) -> int:
m = [float("inf")] * len(envelopes)
m = [inf] * (len(envelopes) + 1)
for _, h in sorted(envelopes, key=lambda x: (x[0], -x[1])):
m[bisect_left(m, h)] = h
return sum(v < float("inf") for v in m)
return m.index(inf)


def set_val(a, v, i):
Expand Down

0 comments on commit 9a19118

Please sign in to comment.