This repository contains work/solutions for
Cracking the Coding Interview: 6th Edition
by Gayle Laakmann McDowell.
The sources (will be) written in C++17.
All sources are WIP (work in progress).
I wanted to have a one-stop solution for practicing coding problems;
the Table of Contents markdown file is hyperlinked with subpages for each chapter --
each chapter page has links to the source files associated with each question.
I am using Visual Studio Code (with a markdown preview extension),
and the Terminal (on macOS).
- Chapter
01
| Arrays and Strings - Chapter
02
| Linked Lists - Chapter
03
| Stacks and Queues - Chapter
04
| Trees and Graphs - Chapter
05
| Bit Manipulation - Chapter
06
| Math and Logic Puzzles - Chapter
07
| Object-Oriented Design - Chapter
08
| Recursion and Dynamic Programming - Chapter
09
| System Design and Scalability - Chapter
10
| Sorting and Searching - Chapter
12
| C and C++ - Chapter
15
| Threads and Locks - Chapter
16
| Moderate - Chapter
17
| Hard
See Completed Question List
for a checklist of questions I have completed.
Please feel free to fork this repository and have your own working copy.
- This folder is not in the repository, but will be generated by CMake when the
makebuilds
script is run.
It is not to be added to the repository -- this directory is in the.gitignore
.
- Markdown documents (aside from
README.md
) are kept here.
- Source files for questions are kept here.
- The first level within
src/
are the chapter directories. - Within a chapter directory is a directory containing the sources for a given question.
- For example:
./src/01/01/
is the directory that contains the sources for
Chapter 01: Arrays and Strings, question 1.1.
- For example:
- A question directory has three files:
main.cpp
header.hpp
source.cpp
- For example, here are the files for
Chapter 01: Arrays and Strings, question 1.1: - You can build and run these sources by invoking
./ctci6 01 01
in the Terminal.- Note: You must have the
cmake
-generatedMakefiles
first.
Run./makebuilds
(just once) to create thebuild
directory.
- Note: You must have the
- Used by
clang-format
to format source code.
- This document.
zsh
script that- runs
make
on the sources of a given question - runs the executable for a given question
- For example: The shell command
./ctci6 01 01
will build and run
Chapter 01: Arrays and Strings, question 1.1.- Note: See
makebuilds
- Note: See
- runs
- Used by
maketarball
to exclude files from the archive generated by said script.
zsh
script for users running a Unix-based operating system, and building withMakefiles
.- Runs
cmake
and creates the following directories with build configurations/Makefiles
:build/make/Debug
build/make/Release
build/make/RelWithDebInfo
build/make/MinSizeRel
- You only need to run
./makebuilds
once.
- Creates a
.tar.gz
archive of this repository. ./maketarball
creates the following file:ctci_edition_06_yyyy-mm-dd_hhmmss.tar.gz;
the boldfaced portion is a timestamp.- You may supply an argument, like this:
./maketarball my_filename.tar.gz
if a different filename is desired.
First, write some source code!
Read the src
section on where to find the sources.
To build,
please have the following installed on your machine:
LLVM (clang)
orgcc
CMake
We will use the Terminal.
Use the provided makebuilds
script to generate Makefiles
.
your_username@your-machine ctci_edition_06 % ./makebuilds
After the Makefiles
are generated,
you will no longer need to use the makebuilds
script.
(unless you delete the generated Makefiles
.)
Then, use the provided ctci6
script to build & run an executable for a given question.
your_username@your-machine ctci_edition_06 % ./ctci6 01 01
The first argument is the chapter number. (Chapter 01)
The second argument is the question number. (Question 1.1)
There is an implicit third argument, which is the build type.
Debug
is the default.
You may supply a third argument; the following are supported:
Debug
Release
RelWithDebInfo
MinSizeRel
The example below runs the same executable in Release
mode.
your_username@your-machine ctci_edition_06 % ./ctci6 01 01 Release
This repository uses CMake. (see https://cmake.org)
Review Building for more details.