Leetcode 1519 Solution
This article provides solution to leetcode question 1519 (minimum-subsequence-in-non-increasing-order)
Access this page by simply typing in "lcs 1519" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order
Solution
class Solution:
def minSubsequence(self, nums: List[int]) -> List[int]:
nums.sort(key=lambda v: -v)
total = sum(nums)
s = 0
ans = []
for v in nums:
s += v
ans.append(v)
if 2 * s - 1 >= total:
break
return ans