Last active
September 4, 2019 03:16
-
-
Save futureperfect/11016201 to your computer and use it in GitHub Desktop.
Collection of small, interesting programming exercises
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hey, | |
This is collection of small, interesting interview practice problems. | |
Hope you get some utility out of this. | |
Erik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function that finds the mode in an array of numbers. | |
The mode is the number which occurs the most within a collection. | |
e.g. | |
findMode([1, 3, 4, 2, 1, 1, 1] => 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given a binary search tree, write a function that returns a list of all nodes at a certain depth D. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function that determines if two strings are anagrams of eachother. | |
e.g. | |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
e.g. | |
merge([1, 2, 5, 5, 10], [3, 7, 10, 11]) => [1, 2, 3, 5, 5, 10, 10, 11] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function to mirror a binary tree. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function that reverses a string. | |
e.g. | |
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