|
1 | 1 | packagecom.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 1300. Sum of Mutated Array Closest to Target |
5 |
| - * |
6 |
| - * Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, |
7 |
| - * the sum of the array gets as close as possible (in absolute difference) to target. |
8 |
| - * In case of a tie, return the minimum such integer. |
9 |
| - * Notice that the answer is not neccesarilly a number from arr. |
10 |
| - * |
11 |
| - * Example 1: |
12 |
| - * Input: arr = [4,9,3], target = 10 |
13 |
| - * Output: 3 |
14 |
| - * Explanation: When using 3 arr converts to [3, 3, 3] which sums 9 and that's the optimal answer. |
15 |
| - * |
16 |
| - * Example 2: |
17 |
| - * Input: arr = [2,3,5], target = 10 |
18 |
| - * Output: 5 |
19 |
| - * |
20 |
| - * Example 3: |
21 |
| - * Input: arr = [60864,25176,27249,21296,20204], target = 56803 |
22 |
| - * Output: 11361 |
23 |
| - * */ |
24 | 3 | publicclass_1300 {
|
25 | 4 | publicstaticclassSolution1 {
|
26 | 5 | publicintfindBestValue(int[]arr,inttarget) {
|
|