Algorithm · Goldman Sachs · Medium
You are given an integer array arr and a non-negative integer maxOps. You may apply up to maxOps increment operations. In one move, choose any index i and raise arr[i] by exactly 1. The moves may be distributed however you like, but the total number of moves cannot exceed maxOps. After all moves are finished, pick an integer value target. Its frequency is the number of positions where the array equals target. Determine the largest possible frequency for any chosen target.…
Checking your access…