Skip to content

Instantly share code, notes, and snippets.

View SCollinA's full-sized avatar

Collin Argo SCollinA

View GitHub Profile
@SCollinA
SCollinA / letterCombos.js
Created April 15, 2019 18:21
get possible letter combinations from a string of digits 2-9 inclusive
/**
* @param {string} digits
* @return {string[]}
*/
// 2 = abc
// 3 = def
// 4 = ghi
// 5 = jkl
// 6 = mno
// 7 = pqrs
@SCollinA
SCollinA / recoverFromPreorder.js
Last active April 15, 2019 17:21
restores a binary tree from a string containing positive integers (representing nodes) separated by dashes (representing branches) (e.g. in: "1-2--3--4-5--6--7", out: [1,2,5,3,4,6,7]
//* Definition for a binary tree node.
function TreeNode(val) {
this.val = val;
this.left = this.right = null;
}
/**
* @param {string} S
* @return {TreeNode}