This repository contains solutions to the interview problems from "Cracking the Coding Interview" by Gayle Laakmann McDowell. The book comes with solutions and Java code, but I thought it would be a good exercise to code up my own solutions in Python. The book contains more than the actual interview problems: resume preparation and interview tips, and inside info about how some of the major companies do their hiring. I thoroughly recommend it.
Each module corresponds to a chapter of the book.
Within each module, files named problemX.py
contain solutions to problem X.
Some files contain main functions, so you can run them, for example:
cd chapter1
python problem1.py
Files named testX.py
contain unit tests for problem X.
To run the unit tests, you need first need to install nosetests and mock:
pip install nose mock
To run the tests for a particular chapter:
cd chapter1
nosetests test1.py
You can also run all the tests by:
nosetests
If you've found a bug or a test case that I'm not covering, please submit a pull request.
If one of the test cases is failing or tripping over an error, you can drop into pdb by re-running nose:
nosetests --pdb
If you'd like to step through a test case from the beginning, add the following line to the test case:
import pdb; pdb.set_trace()
and re-run nose:
nosetests --nocapture