Instantly share code, notes, and snippets.

@futureperfect futureperfect/README
Last active Mar 3, 2017

What would you like to do?
Collection of small, interesting programming exercises
This is collection of small, interesting interview practice problems.
Hope you get some utility out of this.
Given a binary tree and two nodes A and B from within that tree, write a function to find the node which is the first common ancestor of A and B
Write a function that finds the mode in an array of numbers.
The mode is the number which occurs the most within a collection.
findMode([1, 3, 4, 2, 1, 1, 1] => 1
Given a binary search tree, write a function that returns a list of all nodes at a certain depth D.
Write a function that prints the numbers from 1 to 100. EXCEPT:
* If the number if a multiple of 3, print "Fizz" instead of the number
* If the number is a multiple of 5, print "Buzz" instead of the number
* If the number is a multiple of 3 AND 5, print "FizzBuzz" instead of the number
Write a function that determines if two strings are anagrams of eachother.
anagram("FOO", "FOO") => true
anagram("FOO", "BAR") => false
anagram("MARY", "ARMY") => true
anagram("MARRY", "ARMY") => false
Hint: Consider what the essential quality is that makes two words anagrams of each other.
Given a collection of points on a 2D Cartesian plane (i.e. points with an x and y coordinate where axes intersect at 0), write a function to find the k points nearest to the origin.
Write a function that takes as input two sorted arrays of numbers and returns an array which is the combination of the two arrays, also sorted.
merge([1, 2, 5, 5, 10], [3, 7, 10, 11]) => [1, 2, 3, 5, 5, 10, 10, 11]
Write a function to mirror a binary tree.
Write a function that reverses a string.
reverse("bicycle") => "elcycib"
While I'm pleased if you're aware of standard library functions to do so, let's pretend they don't exist for the moment and do the work to write it.
Hint: Worth considering is whether your language has immutable strings or not and how that changes how you might answer this question.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment