This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let russianDoll = (envelopes) => { | |
let maxCount = 0; | |
let indicesUsed = {}; | |
let russianRecurse = (currentCount = 0, lastEnv = [-Infinity, -Infinity]) => { | |
if (currentCount > maxCount) { | |
maxCount = currentCount; | |
} | |
envelopes.forEach((envelope, index) => { | |
if (!indicesUsed[index] && envelope[0] > lastEnv[0] && envelope[1] > lastEnv[1]) { | |
indicesUsed[index] = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cashinator { | |
constructor (initialAmount, taxPercentage, itemList) { | |
} | |
/** | |
* @return {*Current balance in the register} | |
*/ | |
getBalance () { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number} capacity | |
*/ | |
var LFUCache = function(capacity) { | |
this.nodes = {}; | |
this.head = null; | |
this.tail = null; | |
this.size = 0; | |
this.capacity = capacity; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isVowel = (letter) => { | |
return (letter === 'a' || letter === 'e' || letter === 'i' || letter === 'o' || letter === 'u' || letter === 'A' || letter === 'E' || letter === 'I' || letter === 'O' || letter === 'U'); | |
}; | |
let vowelDoubler = (letters) => { | |
for (let i = 0; i < letters.length; i++) { | |
if (isVowel(letters[i])) { | |
letters.splice(i, 0, letters[i]); | |
i++; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number[]} nums | |
* @return {number[]} | |
*/ | |
var productExceptSelf = function(nums) { | |
let products = []; | |
let product = 1; | |
nums.forEach((num, i) => { | |
products[i] = product; | |
product *= num; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hasPathToSum = function(node, targetSum) { | |
let hasSum = (sum, node) => { | |
sum += node.value; | |
if (node.children.length === 0) { | |
if (sum === targetSum) { | |
return true; | |
} else { | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CashAmount { | |
constructor (amount) { | |
this.pennyCount = 0; | |
this.addDoubleAmount(amount); | |
} | |
totalAsPennies () { | |
return this.pennyCount; | |
} | |
totalInPennies () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const findLargestLevel = function(node) { | |
var getAllNodeSums = function(node, nodeSums) { | |
nodeSums.set(node, getNodeSum(node)); | |
for(var i = 0; i < node.children.length; i++) { | |
getAllNodeSums(node.children[i], nodeSums); | |
} | |
} | |
var getNodeSum = function(node) { |