#2769
Find the Maximum Achievable Number
newbie · 135 · lc easy +13 · 91.2% accepted · 520 likes · top 100%
Description
You are given two integers num and t. Call a number x achievable if it can be transformed into num by performing up to t of the following operation:
- Simultaneously increase or decrease x by 1 and decrease or increase num by 1.
Return the largest achievable value of x.
Code
1
2
3