1785. Minimum Elements to Add to Form a Given Sum

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1785

class Solution:
    def minElements(self, nums: List[int], limit: int, goal: int) -> int:
        d = abs(sum(nums) - goal)
        return (d + limit - 1) // limit