1403. Minimum Subsequence in Non-Increasing Order

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

On This Page

LeetCode problem 1403

class Solution:
    def minSubsequence(self, nums: List[int]) -> List[int]:
        res = []
        s, t = sum(nums), 0
        for x in sorted(nums, reverse=True):
            t += x
            res.append(x)
            if t > s - t:
                break
        return res