1053. Minimize Rounding Error to Meet Target

Medium
Array
Math
String
Greedy
Sorting

Description

Hints

Hint 1
If we have integer values in the array then we just need to subtract the target those integer values, so we reduced the problem.
Hint 2
Similarly if we have non integer values we have two options to put them flor(value) or ceil(value) = floor(value) + 1, so the idea is to just subtract floor(value).
Hint 3
Now the problem is different for each position we can sum just add 0 or 1 in order to sum the target, minimizing the deltas. This can be solved with DP.

Statistics

Acceptance
45.7%
Submissions
24,355
Accepted
11,140