Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Notice that for any given time t, the number of flowers blooming at time t is equal to the number of flowers that have started blooming minus the number of flowers that have already stopped blooming.
We can obtain these values efficiently using binary search.
We can store the starting times in sorted order, which then allows us to binary search to find how many flowers have started blooming for a given time t.
We do the same for the ending times to find how many flowers have stopped blooming at time t.