Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. inf = 200000000
  2. def get_lis_nlogn(arr):
  3. I = [inf] * len(arr)
  4. I[0] = -inf
  5. lis_len = 0
  6. for i in range(len(arr)):
  7. low, high = 0, len(arr)
  8. while (low <= high):
  9. mid = (low + high) / 2
  10. if I[mid] < arr[i]:
  11. low += 1
  12. else:
  13. high = mid - 1
  14. I[low] = arr[i]
  15. if lis_len < low:
  16. lis_len = low
  17. return lis_len
  18.  
  19.  
  20. get_lis_nlogn([50, 3, 10, 7, 80, 40])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement