Skip to content

Instantly share code, notes, and snippets.

@trunkslamchest
Last active August 30, 2020 18:23
Show Gist options
  • Save trunkslamchest/462b037c910b32858211868e630e0372 to your computer and use it in GitHub Desktop.
Save trunkslamchest/462b037c910b32858211868e630e0372 to your computer and use it in GitHub Desktop.
blog30_solution_final.js
var minSubsequence = function(nums) {
let sum = nums.reduce((a, b) => a + b ), subSum = 0, sub = []
nums.sort((a, b) => a - b)
for(i = nums.length - 1; i >= 0; i--){
if(sum >= subSum) {
subSum += nums[i]
sum = sum - nums[i]
sub.push(nums[i])
} else break
}
return sub
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment