const groupBy = key => array =>
array.reduce((objectsByKeyValue, obj) => {
const value = obj[key];
objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
return objectsByKeyValue;
This file contains 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
// A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child. | |
// Left child is always less than it's parent and the right child is always bigger than it's parent. | |
class Node { | |
constructor(value) { | |
this.value = value; | |
this.right = null; | |
this.left = null; | |
} | |
} |