Skip to content

Instantly share code, notes, and snippets.

View dmzobel's full-sized avatar

Marshall Zobel dmzobel

View GitHub Profile
@dmzobel
dmzobel / LongestIncreasingSubsequence.md
Created September 6, 2018 21:19
Find the longest increasing subsequence of numbers in an array

Prompt

Given an an array of numbers, find the length of the longest possible subsequence that is increasing. This subsequence can "jump" over numbers in the array. For example in [3, 10, 4, 5] the longest increasing subsequence (LIS) is [3, 4, 5].

Examples

longestIncreasingSubsequence([3, 4, 2, 1, 10, 6]);
// should return 3, the length of the longest increasing subsequence:
// 3, 4, 6 (or 3, 4, 10)
@dmzobel
dmzobel / ImmutableBST.md
Last active March 26, 2020 00:38
Immutable BST Algorithm

Slides

Immutable BST

Prompt

Implement an immutable binary search tree class. The class constructor should accept (at least) a single argument which will represent the value for its root node. Each instance should have two methods: insert, which takes a numerical value and returns a new binary search tree containing that value, and contains, which takes a numerical value and returns true or false based on whether the tree contains it.

Insert should not mutate the existing binary search tree. That is:

@dmzobel
dmzobel / StephCurry.md
Last active March 26, 2020 00:39
Turn normal functions into curried functions

Steph Curry

Interviewer Prompt (a)

Currying is the process by which a function of N arguments is implemented as N single-argument functions such that first of them takes in the first argument and returns a function which takes in the 2nd argument and so on, until the Nth single-argument function finally returns the value of the multi-argument function being implemented.

Your Task:

Write a function called curry that takes a function as an argument, and returns a "curried" version of that function.