Skip to content

Instantly share code, notes, and snippets.

@daniel-trinh
daniel-trinh / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — 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.
Compiling hello_world v0.0.1 (file:///Users/danieltrinh/src/oss/rust_stuff/hello_world)
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-o' '/Users/danieltrinh/src/oss/rust_stuff/hello_world/target/hello_world' '/Users/danieltrinh/src/oss/rust_stuff/hello_world/target/hello_world.o' '-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a' '-nodefaultlibs' '-fno-lto' '-Wl,-dead_strip' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libnative-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libsync-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustrt-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-app
defmodule BST do
defstruct data: nil, left: nil, right: nil
@spec insert(BST.t, any) :: BST.t
def insert(nil, value) do
%BST{data: value}
end
def insert(%BST{data: d, left: l, right: _r} = bst, value) when value > d do
%BST{data: d, left: l, right: insert(bst.right, value)}
end
sealed abstract class BinaryTreeNode[+T] {
def value: T
def left: BinaryTreeNode[T]
def right: BinaryTreeNode[T]
def insert[U >: T <% Ordered[U]](x: U): BinaryTreeNode[U]
def isEnd: Boolean
}
case class BSTNode[+T](
@daniel-trinh
daniel-trinh / prettyPrint.scala
Last active November 11, 2016 09:39
Pretty Print method for formatting case class (as a string input)
def pp(tree: String, indentSize: Int = 2): String = {
var indentLevel = 0
var outputTree = ""
tree foreach { char => char match {
case '(' =>
indentLevel += 1
outputTree += char.toString+'\n'+indents
case ')' =>
indentLevel -= 1
outputTree += "\n" + indents + char.toString