Cracking the Coding Interview - Solutions in C
CTCI/
├── lib/ # Reusable code
├── XX/YY/ # Chapter XX, Problem YY
│ ├── problem.h
│ ├── problem.c
│ └── main.c
├── 00/00/ # Sample problem for testing the build system
├── Makefile # Top-level Makefile
└── README.md
The project uses a top-level Makefile that compiles all .c and .h files in the repository.
- Linux runtime
- GCC compiler
- Make
# Build all problems
make all
# Clean build artifacts
make clean
# Build and run all problems
make run
# Build and run a specific problem (e.g. chapter 01 problem 01)
make run 01/01
# Show help
make helpTo add a new problem:
- Create a directory:
mkdir -p XX/YY(where XX is chapter, YY is problem number) - Add your files:
problem.h- Problem interfaceproblem.c- Problem implementationmain.c- Test cases and main function
- Run
make allto build - Run
make runto test
The Makefile will automatically discover and build your new problem.
The lib/ directory contains reusable data structures and algorithms that can be used across problems. Include them with:
#include "linkedlist.h" // Example library