Skip to content

Instantly share code, notes, and snippets.

package main
import "golang.org/x/tour/tree"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func helper(t *tree.Tree, ch chan int) {
if t != nil {
helper(t.Left, ch)
ch<-t.Value
@tidefield
tidefield / The Technical Interview Cheat Sheet.md
Created February 6, 2016 08:07 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
function where(collection, source) {
var arr = [];
...
return arr;
}
var htmlOut = where([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 })
document.write(htmlOut);
@tidefield
tidefield / fccdebug.html
Last active January 5, 2016 03:28
Free Code Camp's Challenges Debugger
<!DOCTYPE html>
<html>
<head>
<title>FCC Debugger</title>
<script type="text/javascript" src="scripts/whereArtThou.js"></script>
</head>
<body>
</body>
</html>
// Bonfire: Where do I belong
// Author: @daivinhtran
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-do-i-belong
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function where(arr, num) {
// Find my place in this sorted array.
// sort input array
arr.sort(function(a,b){
return a-b;
// Bonfire: Falsy Bouncer
// Author: @daivinhtran
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer
// Learn to Code at Free Code Camp (www.freecodecamp.com)
/*
Remove all falsy values from an array.
Falsy values in javascript are false, null, 0, "", undefined, and NaN.
*/
function bouncer(arr) {
// Don't show a false ID to this bouncer.
// Bonfire: Mutations
// Author: @daivinhtran
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
for (var i = 0; i < arr[1].length; i++){
if(arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) === -1){
return false;
// Bonfire: Slasher Flick
// Author: @daivinhtran
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function slasher(arr, howMany) {
// it doesn't always pay to be first
for(var i = 0; i < howMany; i++){
arr.shift();
}
// Bonfire: Chunky Monkey
// Author: @daivinhtran
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, size) {
// Break it up.
var indexTrack = 0; // used to iterate the input array
var mainArray = [];
// Bonfire: Truncate a string
// Author: @daivinhtran
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function truncate(str, num) {
// Clear out that junk in your trunk
if(str.length > num){
if(num >3)
return str.slice(0,num - 3) + "...";