Solving Sum of Mutated Array Closest to Target in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

In case of a tie, return the minimum such integer.

Example 1:

Input: arr = [4,9,3], target = 10
Output: 3
Explanation: When using 3 arr converts to [3, 3, 3] which sums 9 and that's the optimal answer.

Example 2:

Input: arr = [2,3,5], target = 10
Output: 5

Example 3:

Input: arr = [60864,25176,27249,21296,20204], target = 56803
Output: 11361

Constraints:

  • 1 <= arr.length <= 10^4

  • 1 <= arr[i], target <= 10^5

  • 1 <= arr.length <= 10^4

  • 1 <= arr[i], target <= 10^5

See the full details of the problem Sum of Mutated Array Closest to Target at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go