Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If you sort the original array, it is optimal to apply the operations on one subarray such that all the elements of that subarray become equal.
You can use binary search to find the longest subarray where we can make the elements equal in at most <code>k</code> operations.