Skip to content

Instantly share code, notes, and snippets.

@jykim16
Created September 21, 2017 17:03
Show Gist options
  • Save jykim16/f94a546f95a95affadf72a1c0123700b to your computer and use it in GitHub Desktop.
Save jykim16/f94a546f95a95affadf72a1c0123700b to your computer and use it in GitHub Desktop.
//did not complete
/**
* @param {number[][]} envelopes
* @return {number}
*/
var maxEnvelopes = function(envelopes) {
let max = 0;
let sortedByHeightEnvelopes = envelopes.sort((a,b)=>{return a[0] < b[0]});
let recurseHeight = (currentHeight, remainingEnvelopes, currentCount) => {
var categorizeByHeight = findNextHeightGroup(currentHeight, remainingEnvelopes);
let nextGroupOfEnvelopes = categorizeByHeight[0];
let remainingEnvelopes = categorizeByHeight[1]
}
let findNextHeightGroup = (currentHeight, remainingEnvelopes) => {
let results = [];
let nextHeight;
for (let i = 0; i < remainingEnvelopes.length; i++) {
if(!nextHeight) {
if(remainingEnvelopes[i][0] > currentHeight) {
nextHeight = remainingEnvelopes[i][0];
results.push(remainingEnvelopes[i]);
}
} else if (remainingEnvelopes[i][0] === nextHeight) {
results.push(remainingEnvelopes[i])
}
}
return results;
}
return max;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment