Practice Sum of Mutated Array Closest to Target
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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, the sum of the array gets as close as possible (in absolute difference) to target. In case of a tie, return the minimum such integer. Notice that the answer is not neccesarilly a number from arr.
Source: Sum of Mutated Array Closest to Target on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
arr = [4,9,3], target = 10
3
# Example 2
arr = [2,3,5], target = 10
5
# Example 3
arr = [60864,25176,27249,21296,20204], target = 56803
11361
Constraints
Related LeetCode Problems
Practice more problems similar to Sum of Mutated Array Closest to Target.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.