Cracking the Coding Interview in Python - Solutions with Explanations
Detailed explanations to the coding interview questions in CTCI. The solutions are written in Python 3.
If you find this useful, a Github star would be much appreciated!! ⭐ ⭐ ⭐
Problem Number |
Problem Name |
Status |
3.1 |
Three In One |
❌ |
3.2 |
Stack Min |
❌ |
3.3 |
Stack of Plates |
❌ |
3.4 |
Queue via Stacks |
❌ |
3.5 |
Sort Stack |
❌ |
3.6 |
Animal Shelter |
❌ |
Problem Number |
Problem Name |
Status |
4.1 |
Route Between Nodes |
❌ |
4.2 |
Minimal Tree |
❌ |
4.3 |
List of Depths |
❌ |
4.4 |
Check Balanced |
❌ |
4.5 |
Validate BST |
❌ |
4.6 |
Successor |
❌ |
4.7 |
Build Order |
❌ |
4.8 |
First Common Ancestor |
❌ |
4.9 |
BST Sequence |
❌ |
4.10 |
Check Subtree |
❌ |
4.11 |
Random Node |
❌ |
4.12 |
Paths with Sum |
❌ |
Problem Number |
Problem Name |
Status |
5.1 |
Insertion |
❌ |
5.2 |
Binary to String |
❌ |
5.3 |
Flip Bit to Win |
❌ |
5.4 |
Next Number |
❌ |
5.5 |
Debugger |
❌ |
5.6 |
Conversion |
❌ |
5.7 |
Pairwise Swap |
❌ |
5.8 |
Draw Line |
❌ |
Problem Number |
Problem Name |
Status |
7.1 |
Deck of Cards |
❌ |
7.2 |
Call Center |
❌ |
7.3 |
Jukebox |
❌ |
7.4 |
Parking Lot |
❌ |
7.5 |
Online Book Reader |
❌ |
7.6 |
Jigsaw |
❌ |
7.7 |
Chat Server |
❌ |
7.8 |
Othello |
❌ |
7.9 |
Circular Array |
❌ |
Recursion and Dynamic Programming
Problem Number |
Problem Name |
Status |
8.1 |
Triple Step |
❌ |
8.2 |
Robot in a Grid |
❌ |
8.3 |
Magic Index |
❌ |
8.4 |
Power Set |
❌ |
8.5 |
Recursive Multiply |
❌ |
8.6 |
Towers of Hanoi |
❌ |
8.7 |
Permutation without Dups |
❌ |
8.8 |
Permutation with Dups |
❌ |
8.9 |
Parens |
❌ |
8.10 |
Paint Fill |
❌ |
8.11 |
Coins |
❌ |
8.12 |
Eight Queens |
❌ |
8.13 |
Stack of Boxes |
❌ |
8.14 |
Boolean Evaluation |
❌ |
Problem Number |
Problem Name |
Status |
10.1 |
Sorted Merge |
❌ |
10.2 |
Group Anagram |
❌ |
10.3 |
Search in Rotated Array |
❌ |
10.4 |
Sorted Search, No Size |
❌ |
10.5 |
Sparse Search |
❌ |
10.6 |
Sort Big File |
❌ |
10.7 |
Missing Int |
❌ |
10.8 |
Find Duplicates |
❌ |
10.9 |
Sorted Matrix Search |
❌ |
10.10 |
Rank from Stream |
❌ |
10.11 |
Peaks and Valleys |
❌ |
Problem Number |
Problem Name |
Status |
16.1 |
Number Swapper |
❌ |
16.2 |
Word Frequencies |
❌ |
16.3 |
Intersection |
❌ |
16.4 |
Tic Tac Win |
❌ |
16.5 |
Factorial Zeros |
❌ |
16.6 |
Smallest Difference |
❌ |
16.7 |
Number Max |
❌ |
16.8 |
English Int |
❌ |
16.9 |
Operations |
❌ |
16.10 |
Living People |
❌ |
16.11 |
Diving Board |
❌ |
16.12 |
XML Encoding |
❌ |
16.13 |
Bisect Squares |
❌ |
16.14 |
Best Line |
❌ |
16.15 |
Master Mind |
❌ |
16.16 |
Sub Sort |
❌ |
16.17 |
Contiguous Sequence |
❌ |
16.18 |
Pattern Matching |
❌ |
16.19 |
Pond Sizes |
❌ |
16.20 |
T9 |
❌ |
16.21 |
Sum Swap |
❌ |
16.22 |
Langton's Ant |
❌ |
16.23 |
Rand7 from Rand5 |
❌ |
16.24 |
Pairs with Sum |
❌ |
16.25 |
LRU Cache |
❌ |
16.26 |
Calculator |
❌ |
Problem Number |
Problem Name |
Status |
17.1 |
Add Without Plus |
❌ |
17.2 |
Shuffle |
❌ |
17.3 |
Random Set |
❌ |
17.4 |
Missing Number |
❌ |
17.5 |
Letters and Numbers |
❌ |
17.6 |
Count of 2s |
❌ |
17.7 |
Baby Names |
❌ |
17.8 |
Circus Tower |
❌ |
17.9 |
Kth Multiple |
❌ |
17.10 |
Majority Element |
❌ |
17.11 |
Word Distance |
❌ |
17.12 |
BiNode |
❌ |
17.13 |
Re-Space |
❌ |
17.14 |
Smallest K |
❌ |
17.15 |
Longest Word |
❌ |
17.16 |
The Masseuse |
❌ |
17.17 |
Multi Search |
❌ |
17.18 |
Shortest Supersequence |
❌ |
17.19 |
Missing Two |
❌ |
17.20 |
Continuous Median |
❌ |
17.21 |
Volume of Histogram |
❌ |
17.22 |
Word Transformer |
❌ |
17.23 |
Max Black Square |
❌ |
17.24 |
Max Submatrix |
❌ |
17.25 |
Word Rectangle |
❌ |
17.26 |
Sparse Similarity |
❌ |
If you find this useful, a Github star would be much appreciated!! ⭐ ⭐ ⭐
Pull requests are welcome. For major changes, please open an issue to discuss what you want to change.
Huge thanks to our contributors!