Ezvor

2557. Maximum Number of Integers to Choose From a Range II

MediumArray Preparing judge… LeetCode
ArrayBinary SearchGreedySorting

Hints

Hint 1
It is optimal always to take the smallest possible integer you can choose.
Hint 2
Between every consecutive banned integers, can you find how many integers you can choose?
Hint 3
Think of using binary search to find that.