I made these examples when practicing for interviews. Most of the examples come from Cracking the Coding Interview (5th ed).
These examples are written with a Babel transpiler, so they use modern JavaScript syntax. You don't have to the syntax if you'd just like to use my test cases, but understanding the syntax would certainly help!
I selected a subset of the problems and concepts that I thought would prepare me best for my own interviews, so this isn't a complete list of all the examples from the book.
- There may be mistakes in some of my answers. Not all of the solutions were translated directly from the Java solutions in the book - some I wrote myself without consulting the answers. So be aware that my solutions may be incorrect. The test cases may not cover all the likely errors either.
- I chose to extend base data structure classes with extra functionality for many of the problems. This is of course not a good industry practice, but I found it was the best way to solve these problems with minimal overhead - functional composition would be a bit overkill, and copy-pasting the base classes would be difficult to change. Basically, the higher level design here would be flawed in a bigger project, but it worked fine for practice problems.