Python solutions to algorithm questions in Cracking the Coding Interview.
"TODO" comments are left where more efficient solutions are suggested in the book, or follow-up questions not yet answered.
Each solution, with its tests, should be self-contained inside the one file linked.
Test cases are added as I've understood the problems, and algorithms written to pass these tests.
PRs and issues are welcome where something is incorrect or could be done better!
I run the tests with pytest.
pytest # whole suite
pytest {path_to_test.py} # particular file
-
[Chapter 6 - Math and Logic Puzzles]
-
[Chapter 9 - System Design and Scalibility]
-
[Chapter 11 - Testing]
-
[Chapter 12 - C and C++]
-
[Chapter 13 - Java]
-
[Chapter 14 - Databases]
-
[Chapter 15 - Threads and Locks]
-
- 01_number_swapper
- 02_word_frequencies
- 03_intersection
- 04_tic_tac_toe_win
- 05_factorial_zeroes
- 06_smallest_difference
- 07_number_max
- 08_english_int
- 09_operations
- 10_living_people
- 11_diving_board
- 12_xml_encoding
- 13_bisect_squares
- 14_best_line
- 15_master_mind
- 16_sub_sort
- 17_contiguous_sequence
- 18_pattern_matching
- 19_pond_size
- 20_T9
- 21_sum_swap
- 22_langstons_ant
- 23_rand7_from_rand5
- 24_pairs_with_sum
- 25_LRU_cache
- 26_calculator
-
- 01_add_without_plus
- 02_shuffle
- 04_missing_number
- 05_letters_and_numbers
- 06_number_of_twos
- 07_baby_names
- 08_circus_tower
- 09_kth_multiple
- 10_majority_element
- 11_word_distance
- 12_bi_node
- 13_re_space
- 14_smallest_k
- 15_longest_word
- 16_the_masseuse
- 17_multi_search
- 18_shortest_subsequence
- 19_missing_two
- 20_continuous_median
- 21_volume_of_histogram
- 22_word_transformer
- 23_max_black_square
- 24_max_submatrix
- 25_word_rectangle
- 26_sparse_similarity