Answer: OKCREDIT Hiring | Online Assessment Question | On-Campus (2022)
Answer · Posted Jun 2026
Approach This is a classic Binary Search on Answer problem. Instead of directly finding the answer, we binary search the possible maximum value. For a candidate maximum value mid: Calculate how many operations are needed to make every number ≤ mid. If required operations ≤ k, then mid is achievable. Otherwise, increase the candidate value. Strategy Binary Search Range Lowest Possible Maximum = 1 Highest Possible Maximum = max(nums) Operations Required For a number n > maxVal: Operations = ceil(n ...
The full answer & interview discussion are available to premium members.
Log in Create a free account