Å·±¦ÓéÀÖ

Jump to ratings and reviews
Rate this book

Cracking the Coding Interview: 150 Programming Questions and Solutions

Rate this book
Now in the 5th edition, Cracking the Coding Interview gives you the interview preparation you need to get the top software developer jobs. This is a deeply technical book and focuses on the software engineering skills to ace your interview. The book is over 500 pages and includes 150 programming interview questions and answers , as well as other advice.Ìý

The full list of topics are as

The Interview Process This section offers an overview on questions are selected and how you will be evaluated. What happens when you get a question wrong? When should you start preparing, and how? What language should you use? All these questions and more are answered.
Behind the Scenes Learn what happens behind the scenes during your interview, how decisions really get made, who you interview with, and what they ask you. Companies covered include Google, Amazon, Yahoo, Microsoft, Apple and Facebook.
Special Situations This section explains the process for experience candidates, Program Managers, Dev Managers, Testers / SDETs, and more. Learn what your interviewers are looking for and how much code you need to know.
Before the Interview In order to ace the interview, you first need to get an interview. This section describes what a software engineer's resume should look like and what you should be doing well before your interview.
Behavioral Preparation Although most of a software engineering interview will be technical, behavioral questions matter too. This section covers how to prepare for behavioral questions and how to give strong, structured responses.
Technical Questions (+ 5 Algorithm Approaches) This section covers how to prepare for technical questions (without wasting your time) and teaches actionable ways to solve the trickiest algorithm problems. It also teaches you what exactly "good coding" is when it comes to an interview.
150 Programming Questions and Answers This section forms the bulk of the book. Each section opens with a discussion of the core knowledge and strategies to tackle this type of question, diving into exactly how you break down and solve it. Topics covered includeÌý For the widest degree of readability, the solutions are almost entirely written with Java (with the exception of C / C++ questions). A link is provided with the book so that you can download, compile, and play with the solutions yourself.
Changes from the Fourth Ìý The fifth edition includes over 200 pages of new content, bringing the book from 300 pages to over 500 pages. Major revisions were done to almost every solution, including a number of alternate solutions added. The introductory chapters were massively expanded, as were the opening of each of the chapters under Technical Questions. In addition, 24 new questions were added.
Cracking the Coding Interview, Fifth Edition is the most expansive, detailed guide on how to ace your software development / programming interviews.

500 pages, Paperback

First published October 14, 2008

1,381 people are currently reading
14.2k people want to read

About the author

Gayle Laakmann McDowell

17Ìýbooks303Ìýfollowers
Gayle Laakmann McDowell is the founder / CEO of CareerCup, and the author of Cracking the PM Interview, Cracking the Coding Interview, and Cracking the Tech Career.

Gayle has worked for Microsoft, Apple and Google as a software engineer. She holds a bachelor's and master's degree from the University of Pennsylvania in Computer Science, and an MBA from the Wharton School. She currently resides in Palo Alto, CA.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
3,573 (52%)
4 stars
2,258 (32%)
3 stars
816 (11%)
2 stars
145 (2%)
1 star
65 (<1%)
Displaying 1 - 30 of 278 reviews
Profile Image for Rod Hilton.
151 reviews3,117 followers
July 24, 2017
Indispensable.

I absolutely hate the way technical interviews are done for programmers. Can you imagine if a heart surgeon went to interview at a hospital, and they handed him a game of "Operation" to play? That's how we interview programmers. It's so stupid, I could go on and on about it for paragraphs.

But, if you want to work at the top tech companies in the world, you have to play the game, incredibly stupid and poorly aligned it is to the task at hand. And if you're about to head out on some coding interviews, reading Cracking the Coding Interview is the single most important thing you can do for yourself. It's simply phenomenal.

There are definitely some sections that Gayle doesn't seem particularly interested in. For example, the coverage of Bit Manipulation seemed a bit cursory, like it's an area that she's not super familiar with or comfortable with herself. But for the most part, all of the major stuff is covered, in the right level of detail. It's good to review but if you weren't already somewhat familiar with a lot of these data structures and concepts, I'm not sure that the book works as an introduction.

One major omission is the coverage of Tries. They get a shout-out as a data structure that basically doesn't show up in interviews, but I interviewed at 5 major tech companies after reading this book and Tries were the right solution in three of them.

Overall though, the reason to get this book is for the set of questions. Questions that are exactly the kind of things you get asked in coding interviews. Each question has some hints, as well as the answers in the back. Take the book, and practice solving the problems on an actual whiteboard. Don't skip to the answers, but feel free to read the hints (most interviewers will provide similar hints).

There's simply nothing else you can do that better emulates the coding interview than practicing the problems in this book. It's a must-have.
Profile Image for Zeyuan Hu.
15 reviews1 follower
February 1, 2015
This makes me not want to be a programmer or a developer.
Profile Image for Maxim Perepelitsyn.
21 reviews10 followers
March 4, 2023
I am very negative about hiring practices in the US software industry, where often for a pizza delivery kind of job they interview as if they need a space ship pilot. And this book and many similar ones are culmination of this flawed approach, that forces people to memorize tricky tasks and their solutions instead of developing strong CS and Math backgrounds.

Overall the book was OK to get a taste of what insanity to expect on coding interviews. But almost every topic in the book is covered much better elsewhere.
Profile Image for Mohamed Elsherif.
32 reviews270 followers
December 28, 2017
For better or for worse, this book is a must read for any developer, at least from pragmatic point of view, I personally don't see the current interview practices any good, but reality is reality.
Profile Image for Ryan McCarthy.
336 reviews21 followers
January 28, 2021
A fantastic resource that I never want to have to read again.
Profile Image for Molly.
15 reviews5 followers
March 21, 2017
I was searching for software engineering internships for this summer. Before reading this book, I failed all four tech interviews with various companies, 2 bigger companies and 2 startups. And then I got more interviews, and I decided to spend an weekend reading this book. I passed the subsequent interviews with three companies, including Google and a hot SF startup. I learned some key crucial techniques from this book which I applied to my latter interviews, they are:

1. Talk out loud so that your interviewer can be on the same page of where you are in your thinking process and can correct you if you go awry.
2. Use simple examples to help thinking. It's a lot easier to think about a concrete example than an abstract problem.
3. Various techniques to decrease time and space complexity of your algorithm.
4. A different way to look at technical interview: it's not about solving the problem, it's about showing your thinking process and logic reasoning capabilities.

Really recommend to anyone prepping for coding interviews.
2 reviews2 followers
February 21, 2016
This book is a must have for any software engineer. It doesn't matter whether you already have the perfect job or you are a college graduate, who needs to find your first job - it provides a good base for how programming interviews are done in the majority of the software companies.

The book is structured in two parts: overview of how interviews for software engineers proceed and actual coding exercises with hints and complete answers.

The overview of the interview process focuses on how most of the interviews in the software companies are done and confirming the fact that majority of the time in these interviews is spent actually coding on whiteboard, which for bad or good is quite different than coding on a computer. Probably the main take aways are:

The goal of the coding in the interview process is not to find out what you know, but how you approach and think through a problem, which you've never encountered before. Observing what you know is a side-effect of facing unfamiliar problem, which often requires application of knowledge you already know.
No one expects you to solve a problem immediately or in one try. The goal is to see how you react to unfamiliar situation - ability to find information, analyze the problem looking for a starting point, etc.
On similar note, no one expects to be able to answer all the questions. You are graded not based on whether you answered all questions or not, but on how well you perform against other interview candidates.
Profile Image for Heather.
119 reviews12 followers
March 11, 2013
This is a great interview prep book, and I would recommend catering your focus to the types of companies you're interviewing with.

In general, most companies probably aren't going to give you questions from math/probability and brain teasers (the exception is the big-name companies the author mentions, Microsoft, Google, Amazon, etc.).

I actually brushed up on the java section last night before an interview today, and believe it or not, I was asked about a topic from the java overview (I was thankful I had the refresher!). For that reason alone, I'm giving this a 4 star rating :-)
Profile Image for Vitaliy Zasadnyy.
26 reviews13 followers
March 2, 2020
One of the best books to prepare to the technical interview. It covers everything starting from questions on your previous experience and finishing hardcore algorithms.

If you have 3+ month before your first tech interview - this book is probably your best bet.

And it works, thanks to it (and bunch of others) I managed to get offers from Facebook and Google.
18 reviews
November 9, 2013
The list of questions and solutions is not comprehensive, but I guess that is the point. Coding interviews are about judging your approach to problems rather than specific solutions. I found that some of the problems were quite simple compared to the difficulty level currently in force at various companies. In particular would like to see more dynamic programming problems.

But the way the solutions are laid out is amazing. Although you should try to solve it yourself before reading the solutions, once you have solved it, you should read the solutions anyway, because he explains the approach he has taken to solve the problems and that turns out to be very valuable.

Overall, very useful - not just for people looking for change, but for every one looking to keep their mind sharp and fresh.
11 reviews
November 25, 2017
This book attempts to define *the* format for programming interviews, equating interviewing with competitive programming, which is the type of programming used at events like IEEE Xtreme or ACM ICPC (among others).

Competitive programming has a lot of merit, and provides a tangible demonstration of some of the programmer's abilities, but in many cases, high performance in these tasks will not be a predictor of on-the-job performance. In this regard, "Cracking the Coding Interview" is a bit of a disservice to the software engineering interviewing process.

If you wish however, to get better at this interviewing format, I would rather recommend the following resources:
- Learning: Sedgewick's algorithms book and video course.
- Exercises: InterviewBit, Topcoder.

In addition to that, a competitive programming book. I recommend "Competitive Programmer's Handbook" by Antti Laaksonen (), which provides programmer to programmer advice, in a linear, easy to follow format, with code examples.
Profile Image for Tim O'Hearn.
AuthorÌý1 book1,190 followers
August 30, 2018
I've been through this book, front to back, many times, and, this time, I've shelved it with great optimism. So here's to you, Gayle. You've helped mediocre students like me to chase their wildest dreams without concession.

Reviewing CtCI has traditionally been considered the best way to test Software Engineering fundamentals among those entering the industry. With the popularization of interactive platforms like HackerRank and Leetcode, it has become a rite of passage among undergraduates to grind practice problems for hundreds of hours. The result of this leading to highly-desireable career outcomes is that 1. You have a lot of people studying Computer Science for the wrong reason (E.G. CS is the new pre-med) and 2. Most other skills that are important for those working in the industry are deemphasized. 3. There is increased homogeneity in an almost exclusively negative sense.

I don't place the blame on Gayle for what has happened nor do I blame companies that use permutations of these classic problems to screen tens of thousands of candidates. Many people who studied Computer Science did so because they saw it as the best way to satisfy their desire to solve interesting problems and hate it if you must, but this is just a book filled with fun little problems to solve. You signed up for it! Getting toasted in a Facebook interview doesn't mean that the candidate evaluation process is broken!

Anyway, it's a classic book. People probably recommend "better" things now but, as you can probably imagine, most of the problems you'll find elsewhere will be similar if not identical. I'm getting a bit old for this now, though, and I'm hoping I never have to open the book again.

Profile Image for afloatingpoint.
190 reviews31 followers
January 14, 2016
I have not finished all the exercises in here, but the book did give me a good idea what to expect in a tech interview. Not related to the book, but I found this complete, comprehensive solution set in other languages on github:
Profile Image for Khoi Nguyen.
38 reviews5 followers
March 9, 2021
It is so great to have detailed advice about everything of a coding interview. Clear writing, straight-forward discussion about salary-dealing or why algorithmic interviews are still dominant.
Profile Image for Ugur.
230 reviews217 followers
August 21, 2022
Cracking the Coding Interview is one of the best books to remember old topics. If you are still coding or like coding this book is a great resource to practice old topics. Most of the topics are not too detailed but it is good to check the abstracts.

After reading this book, you probably need more detailed books for each subject.

- Arrays and Strings
- Linked Lists
- Stacks and Queues
- Trees and Graphs
- Bit Manipulation
- Brain Teasers
- Mathematics and Probability
- Object-Oriented Design
- Recursion and Dynamic Programming
- Sorting and Searching
- Scalability and Memory Limits
- Testing
- C and C++
- Java
- Databases
- Threads and Locks
Reviewed on December 29, 2014
Overall: 4.0/5.0
Profile Image for Prakash.
154 reviews88 followers
May 21, 2016
3.5/5

There are some problems with the book. When the code is large, the comments go missing. Literally, you might begin to bang your head against a wall, when you have 2 pages of code and the functions are missing the info what they do.

A program should be extremely readable if it is given in a book, and hence heavily commented.

Coming to OOP section, some solutions are horrible. One example would be the car park one.

Otherwise the book is great. Maybe the Test chapter should be skipped, people from testing profile won't buy the book, and those who WILL buy are not looking for testing profile.

The DP programming questions don't have very good solutions. And don't even think about learning DP approach from here. You won't be able to.

Profile Image for David Dvali.
18 reviews2 followers
May 13, 2020
I can not say it is a bad book. But I think, long analysis of solutions makes solution harder (when it is not), which is in this case. Sometimes I was writing solution by myself and understanding how it works, but looking solution in the book and needed time to figure out what it was saying. It is my position. Someone may find it really helpful this solutions. But also in many cases my written code was better (readable) than in the book. My suggestion is do not read this book in one go. It is too much
24 reviews
May 1, 2012
This is a must read book for all engineers looking for work. It goes over how to act as well as coding/behavioral questions. A related site for more examples can be found here:

Again, this is a must read book (and fast read). It will let you know what areas to improve on and which ones are normally asked (and they really do get asked!)
Profile Image for Sandy Maguire.
AuthorÌý3 books192 followers
June 12, 2014
I think I preferred Skiena's Algorithm Design Manual as a refresher on algorithms/interview prep, but this book is also very good (and easier to find!). Let's see if it gets me the job!
Profile Image for Islomjon.
164 reviews5 followers
September 30, 2020
Even though "Cracking the Coding Interview" looks voluminous, it is read fast due to more than 50% of pages are devoted to solutions. Author tries to generalize the interview process of a developer, although there are several companies and so various processes to hire a programmer. Her advice is realistic and logical; discussed technical topics are indeed relevant (and hard to implement in interview). She summarized almost all subjects that computer scientist studies as an undergraduate such as Algorithms, Data Structures and Database. Moreover, the book could be used as a guideline to prepare yourself to an interview or to test yourself in solving some questions and check their solutions. As a software engineer student, I highly recommend to read this book at least one year before graduation and solve exercises and understand main logic.
Profile Image for Roman.
85 reviews1 follower
November 5, 2020
This book has some decent information about how to walk through problems, think about Big O time complexity, and prepare for interviews from months out, weeks out, and days out. However, I think that LeetCode has better problems and a better environment to practice in. My recommendation would be to read the beginning chapters first, and then switch to LeetCode when you're ready to start doing problems.
12 reviews2 followers
July 18, 2018
This book is a must read for coding interview preparation. Not only the questions are great but Gayle explains the approach to breakdown different problems into steps so that you can easily tackle problems you have never solved before.

This book helped me in my placement interviews and I was able to crack interviews of companies like Oracle, Amazon easily.

333 reviews24 followers
February 26, 2019
Targeted to the software engineer, the data scientist will also find some valuable information in this book. The first chapters are general enough that the description of the interview process, difference between different tech companies, behavioural questions, etc, shall apply to both engineers and scientists. Then I really enjoyed the sections on math and logic puzzles and the advanced topics on math. Of course, the bulk of the book, on coding, will mainly interest the software engineer.
Profile Image for Yura Gavrilovich.
100 reviews7 followers
May 13, 2020
Great book for preparing for the coding interview. Explains how a typical interview goes in big corporations like Google, Amazon, etc. Gives you concrete steps to prepare yourself for all interview stages. And the most important part, which takes ~70% of the book, problems with detailed solutions. Prepare to spend most of your time not reading the book, but solving problems.
Profile Image for Huy Nguyá»…n.
2 reviews
May 30, 2021
- Realistic, easy to read for people majoring in Computer Science and preparing for job interviews
- Good sample questions for whiteboarding interview (currently doing some exercises in the books, but other sources such as leetcode, hackerrank are also great)
- Lack some example of non-whiteboarding inrterview (small + middle companies)
Profile Image for Endilie Yacop Sucipto.
4 reviews3 followers
December 27, 2017
While CtCi is a great coding interview prep book, I still believe that it is slightly over-rated. It should be read with other books, not as a standalone due to lack of explanation in some parts.

Overall, I'd recommend this book to someone who had never read other coding interview prep book.
Profile Image for Vaibhav Singh.
21 reviews
May 3, 2018
The best book for coding interviews, period. Gayle Laakmann McDowell cuts through the crap and clearly establishes what is important and what is not. Also, this book serves as a guide for a lot of recruiters out there.
Profile Image for Alek.
72 reviews27 followers
February 15, 2022
This is a pretty good book for the time. But today, the interview preparation process is simpler and more streamlined. Just go practice problems on LeetCode. Also, Java was the language then, but I think it has now been superseded by Python.
Profile Image for Anna.
872 reviews22 followers
Want to read
December 17, 2018
I have so, so much to learn. It’s as if people get college degrees in this stuff!
Displaying 1 - 30 of 278 reviews

Join the discussion

Can't find what you're looking for?

Get help and learn more about the design.