Guest User

Untitled

a guest
Nov 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. import bisect
  2. class Solution:
  3. def lengthOfLIS(self, nums):
  4. """
  5. :type nums: List[int]
  6. :rtype: int
  7. """
  8. dp = []
  9. for n in nums:
  10. pos = bisect.bisect_left(dp, n)
  11. if pos == len(dp):
  12. dp.append(n)
  13. else:
  14. dp[pos] = n
  15. return len(dp)
Add Comment
Please, Sign In to add comment