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
/* | |
Useful for HackerRank problems. | |
*/ | |
function main (numNodes, edges) { | |
const parent = []; | |
const rank = []; | |
function makeSet (x) { |
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
I) About me: | |
a) Peter Hayes, engineer at ClassDojo | |
b) Studied mathematical economics at Brown, used to be a high school math teacher | |
c) Follow me on github/check out my npm. don't follow my twitter | |
II) Introduction | |
a) Topics today: heaps, quadtrees, graphs | |
b) What are data structures for? | |
1) Not just to store data - an unstructured blob can store data | |
3) Rather: store data with *efficient* insertion, access, and retrieval |
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
On schoolTeacher resource: | |
{ | |
_items: [ | |
{ | |
_id: 1234 | |
... | |
_links: { | |
befriend/poolWith/etc: { | |
href: "/api/teacher/1234/friends", | |
method: "POST", |
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
// We write the problem as a table. Each row represents the amount of change to make, | |
// and the value at each column represents the highest coin we're allowed to use | |
// in making that amount of change | |
// That is to say, in row 5, col 2 is the number of ways to make 5 cents, using only the two lowest coins. | |
// To calculate the value of each square, we add the values of two other squares together - | |
// * The square to the left, which represents all possibilites using smaller coins. | |
// * The square as many rows above as the value of that coin. | |
// This is all possibilities after taking away one of this coin | |
// This method avoids having to ever call things recursively - we just build a big table! |
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 integrate = function() { | |
// return 42; | |
var iters = 2000; | |
var d = getGraphDimensions(); | |
var width = d.x.max - d.x.min; | |
var height = d.y.max - d.y.min; | |
var xmin = d.x.min; |