Skip to content

Instantly share code, notes, and snippets.

//which children have the largest sum node values
//input: node
//output: level of tree
//use breadth first search, using a cue; first in last out;
//edge: in case of tie, use level closest to root.
//sum of children;
@austinreuter
austinreuter / pascals.js
Created July 13, 2017 16:58
Pascal's triangle interview q
var generate = function(numRows) {
if (numRows === 0) {
return [];
}
var output = [[1]];
if (numRows === 1) {
return output;
}
for (var i = 0; i < numRows; i++) {
var last = [];
//so, Scrimba had uneccessary "unexpected token" errors that do not exist on replit. Lots of time spent debugging things that don't need debugging
console.log('dog');
var each = function(collection, callback) {
if (Array.isArray(collection)) {
for (var i = 0; i < collection.length; i++) {
callback(collection[i], i, collection);
}
} else {
for (var key in collection) {
//https://scrimba.com/casts/cNgwQA3
//take array of objects;
//within each object; access name property: access first last prop names;
//return array of strings: "first last";
function isTeenager(salesTeam) {
//return only names that are 18 and 13, inclusive;
//iterate through each object;
function billTotal(subtotal) {
//input number
//output is number with tip and tax;
var tip = subtotal * 0.15;
var tax = subtotal * 0.095;
return subtotal + tip + tax;
}
function assert(actual, testName) {
if (!actual) {
console.log('FAILED ' + testName);
@austinreuter
austinreuter / 0_reuse_code.js
Created May 7, 2017 21:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console