|
3 | 3 | * Find the Maximum Achievable Number
|
4 | 4 | **
|
5 | 5 | * You are given two integers, num and t.
|
6 |
| - * An integer x is called achievable if it can become equal to num after applying the following operation no more than t times: |
7 |
| - * Increase or decrease x by 1, and simultaneously increase or decrease num by 1. |
| 6 | + * An integer x is called achievable if it can become equal to num |
| 7 | + * after applying the following operation no more than t times: |
| 8 | + * Increase or decrease x by 1, |
| 9 | + * and simultaneously increase or decrease num by 1. |
8 | 10 | *
|
9 |
| - * Return the maximum possible achievable number. It can be proven that there exists at least one achievable number. |
| 11 | + * Return the maximum possible achievable number. |
| 12 | + * It can be proven that there exists at least one achievable number. |
10 | 13 | *
|
11 | 14 | * Example 1:
|
12 | 15 | * Input: num = 4, t = 1
|
13 | 16 | * Output: 6
|
14 | 17 | * Explanation:
|
15 |
| - * The maximum achievable number is x = 6; it can become equal to num after performing this operation: |
| 18 | + * The maximum achievable number is x = 6; |
| 19 | + * it can become equal to num after performing this operation: |
16 | 20 | * 1- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
|
17 | 21 | * It can be proven that there is no achievable number larger than 6.
|
18 | 22 | *
|
|
25 | 29 | * 2- Decrease x by 1, and increase num by 1. Now, x = 5 and num = 5.
|
26 | 30 | * It can be proven that there is no achievable number larger than 7.
|
27 | 31 | *
|
28 |
| - * Constraints: 1 <= num, t <= 50 |
| 32 | + * Constraints: |
| 33 | + * • 1 <= num, t <= 50 |
29 | 34 | *
|
30 |
| - * Hint: Let x be the answer, it’s always optimal to decrease x in each operation and increase nums. |
| 35 | + * Hint: |
| 36 | + * Let x be the answer, |
| 37 | + * it’s always optimal to decrease x in each operation and increase nums. |
31 | 38 | **
|
32 | 39 | * https://leetcode.com/problems/find-the-maximum-achievable-number/
|
33 | 40 | ***/
|
|
0 commit comments