Last updated 5 months ago
Using binary search:
=> Remember this code
left = 0 right = len(nums) - 1 while left < right: mid = left + (right-left)//2 count = 0 for num in nums: if num <= mid: count += 1 if count <= mid: left = mid + 1 else: right = mid return left