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
var kthSmallest = function(binaryTree, k) { | |
var arr = []; | |
var search = function(tree) { | |
if (arr.length<k) { | |
arr.push(tree.value) | |
search(tree.left); | |
search(tree.right); | |
} else { | |
if (tree.value < Math.max(arr)) { | |
arr.splice(arr.indexOf(Math.max(arr))); |
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(double) { | |
this.amount = double; | |
} | |
totalAsPennies() { | |
return Math.floor(this.amount*100); | |
} | |
addDoubleAmount(double) { |
NewerOlder