- public List
minSubsequence(int[] nums) { - int n=nums.length;
- List
ans=new ArrayList<>(); - int sum=0;
- for(int i=0;i
- sum+=nums[i];
- }
- Arrays.sort(nums);
- int tmp=0;
- for(int i=n-1;i>=0;i--){
- tmp+=nums[i];
- ans.add(nums[i]);
- if(tmp>sum/2)
- break;
-
- }
- return ans;
- }