You are given an integer array prizePositions sorted in non decreasing order, representing the coordinates of prizes placed along a number line. Multiple prizes may share the same position. You are also given an integer k.
You may choose k. A segment covering the interval k if k. A prize is collected if its position lies within either of the chosen segments.
Return the maximum number of prizes you can collect.
Note: The
segments may overlap, but each prize can only be counted at most once.
Constraints:
prizePositions.length
prizePositions[i]
k
prizePositions is sorted in non decreasing order.
You are given an integer array prizePositions sorted in non decreasing order, representing the coordinates of prizes placed along a number line. Multiple prizes may share the same position. You are also given an integer k.
You may choose k. A segment covering the interval k if k. A prize is collected if its position lies within either of the chosen segments.
Return the maximum number of prizes you can collect.
Note: The
segments may overlap, but each prize can only be counted at most once.
Constraints:
prizePositions.length
prizePositions[i]
k
prizePositions is sorted in non decreasing order.