CS interviews are a different breed from other interviews and, as such, require specialized skills and techniques. This talk will teach you how to prepare for coding and PM interviews, what top companies like Google, Amazon, and Microsoft really look for, and how to tackle the toughest programming and algorithm problems. This is not a fluffy be-your-best talk; it is deeply technical and will discuss specific algorithm and data structure topics.
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Cracking the Coding Interview (Master Slide Deck)
1. Cracking the Coding
(& PM) Interview
Advice and Strategies for Software Engineering
and Product Management Interviews
Gayle Laakmann McDowell
Founder / CEO, CareerCup.com
Author of Cracking the Coding Interview,
Cracking the PM Interview, & The Google Resume
McDowell | CareerCup.com
January 2014
2. Technical Skills
Behavioral
Applying
My Background
• Software Engineer @ Google, Microsoft & Apple
– 3 Years on Google Hiring Committee
– Interviewed 150+ candidates
• Founder of CareerCup.com
• Author
– Cracking the Coding Interview
– The Google Resume
– Cracking the PM Interview [Product Management]
Process
• Interview coach for acquisitions & acquihires
McDowell | CareerCup.com
4. Technical Skills
Most Common CS Jobs
Big Company
Behavioral
PM
Dev
SDET
Startup
Research
Start Your
Own
Dev
Research
DO ALL
THE
THINGS
Senior & Up
Process
Applying
Junior
Sophomore
Freshman
McDowell | CareerCup.com
5. Technical Skills
Behavioral
Product Manager (“PM”)
==
“Associate Product Manager”
(Google, Yahoo, Facebook, etc.)
==
“Program Manager”
(Microsoft)
Process
Applying
What is a Product Manager?
McDowell | CareerCup.com
6. Technical Skills
Behavioral
• Manage the PRODUCT, not the PEOPLE
• “Build a great product for the users”
– Who are the users?
– What are the features?
– When will we launch?
– How do we launch?
– etc
Process
Applying
What is a Product Manager?
McDowell | CareerCup.com
8. Technical Skills
Behavioral
• Write code (duh)
• Architect systems
• Plus sometimes:
– Write specs
– Talk to users
– Figure out feature set
– Etc
Process
Applying
What is a Programmer?
McDowell | CareerCup.com
10. • Figure out what needs to be tested and
how
• Write code to automate testing
Technical Skills
Process
Applying
Behavioral
What is an SDET?
McDowell | CareerCup.com
12. • 5 - 10 min – Qs about resume
• 40 min – technical Qs
– Coding and algorithms
• 5 – 10 min – let you ask Qs, general
wrap up, etc
Technical Skills
Process
Applying
Behavioral
What to Expect
McDowell | CareerCup.com
13. Technical Skills
Big Company Evaluation (Devs)
Coding
Skills
Intelligence
Process
Applying
Behavioral
Experience
Personality
McDowell | CareerCup.com
Testing
aptitude, not
knowledge
14. Technical Skills
Behavioral
Applying
Process
Start-Ups
• Coding + Intelligence
• “Hit the ground running”
– Do you know “their” technologies?
• Entrepreneurial
– Have you started things?
– How much direction do you need?
but…
• Personality
it varies!
– Will you fit with the team?
McDowell | CareerCup.com
16. Technical Skills
Behavioral
Applying
Process
How You Are Judged
How did you do RELATIVE
to other candidates on
the SAME question?
It’s not about how
quickly you solved
the problem…
… it’s about how quickly
you solved it relative to
other candidates.
McDowell | CareerCup.com
18. Technical Skills
How to Get an Interview
– Education
– Work Experience
– Projects
– Github / Online Profile
• Make a kick-ass resume
Process
Applying
Behavioral
• Your “Pedigree”
McDowell | CareerCup.com
20. Technical Skills
How We Review Resumes
3.
Applying
Behavioral
1.
2.
Reject
4.
Process
Pull resume out of giant stack
Spot-check: company names,
positions, projects, schools.
Skim bullets to see if you’ve
written real code.
Interview
Go to next resume & whine about
how many more you have left.
McDowell | CareerCup.com
“Glanced
at,” not read.
15 – 30
seconds
21. How CS Resume
Should Look
One Page Only!
Unless > 10 years exp.
A Real Resume Format
with organized columns
Short (1 – 2 line bullets)
Focus on Accomplishments
not responsibilities
GPA if at least 3.0
max (in-major, overall)
3 – 4 Projects
Courses & independent
Finished or unfinished
List of Technical Skills
Short! Cut the “fluff.”
Observe: No Objective!
Objectives / summaries are
almost always useless.
22. Technical Skills
Talking to Recruiters
– What you’ve done (mobile app? Show it!)
– What you’re excited about
• Have a “pitch” ready
• Weird is okay
– (arrogant is not)
Process
Applying
Behavioral
• Show:
McDowell | CareerCup.com
24. Technical Skills
Behavioral
• Answer the question.
• Deliver a good answer.
• Communicate well.
– Nugget First
– S.A.R.: Situation, Action, Result
Process
Applying
Goals of Your Answer
McDowell | CareerCup.com
25. Technical Skills
Preparing for Behavioral Qs
• Create Preparation Grid for Projects
Behavioral
OS Project
Amazon Intern.
Enjoyed
Hated
Applying
Most Challenging
Hardest Bug
Process
+ Behavioral Grid [for PM & less tech. roles]
McDowell | CareerCup.com
26. Technical Skills
Structure 1: Nugget First
Behavioral
• Lead with your “thesis” / nugget
– Grabs the listener’s attention
– Gives them context for where you’re going.
A: I’m most proud of the way I
re-architected the …
Process
Applying
Q: What accomplishment are you
most proud of?
McDowell | CareerCup.com
27. Technical Skills
Structure 2: S.A.R.
What was the issue?
A ction
What did you do about it?
R esult
What was the impact?
Process
Applying
Behavioral
S ituation
McDowell | CareerCup.com
28. Technical Skills
Good Questions for Interviewer
Behavioral
• Qs you want to get answered
– How decisions get made
– Interaction betw devs, PMs, testers
• Qs that show interest / passion
• Qs that show knowledge / aptitude
– How did you solve problem with ___?
Don’t worry too much
about this stuff
Process
Applying
– What’s the architecture like?
McDowell | CareerCup.com
30. Technical Skills
How to study
• Study the basics
Behavioral
• Practice solving questions
Applying
– Complex algorithms generally unnecessary.
• Push yourself!
• Write code on paper
Process
– Don’t memorize!
– See: CtCI & CareerCup.com
McDowell | CareerCup.com
31. Technical Skills
Behavioral
Data Structures
• How to implement
• When to use (pros / cons)
Queues
Trees
Tries
Graphs
Vectors
Applying
Stacks
Heaps
Hashtables
Process
Linked Lists
McDowell | CareerCup.com
32. Technical Skills
Behavioral
• Implementation
• Space vs. Time
Complexity
Quick Sort
Merge Sort
Tree Insert / Find
Binary Search
Breadth-First
Search
Depth-First
Search
Process
Applying
Algorithms
McDowell | CareerCup.com
33. Technical Skills
Concepts
Behavioral
• Not just a concept – know how to code!
Big-O
Time / Space
Memory
Management
Recursion
Probability +
Combinatorics
Bit Manipulation
Process
Applying
Threading
McDowell | CareerCup.com
34. Technical Skills
Behavioral
• Necessary for “elite” tech companies
– Not necessarily otherwise (check interview
questions)
• MIT Open Courseware
– Freshman / sophomore level DS & Algo
courses
• Books
– CLRS (Algorithms)
• Online tutorials
• Practice implementing and using
Process
Applying
How to Learn CS Fundamentals?
McDowell | CareerCup.com
41. Technical Skills
Behavioral
Applying
Process
Product Design Qs: Example
How would you design a calculator for the blind?
Step 2: Understand the User
• What’s important to a blind child?
– Keeping up with the rest of the class
– Not feeling “different”
– Efficient input / output
• What about teachers, parents,
classmates, etc.?
42. Technical Skills
Behavioral
Product Design Qs: Example
How would you design a calculator for the blind?
Step 3: Structure
• Find a structure
– Otherwise, you’re just blabbering
Process
Applying
• One approach:
1.
2.
3.
4.
Make list of functions necessary
Discuss how to do input / output
Usability for non-blind
Summary
46. Technical Skills
Estimation Qs: How to Approach
1. Ask questions to resolve ambiguity
Applying
Behavioral
– Don’t make assumptions (yet)
2. Outline / Structure Your Approach
3. Break down the components
– Assume numbers when necessary
– State assumptions explicitly
– Round numbers to make your math easier
4. Sanity Check
Process
– Do your numbers make sense?
47. Technical Skills
Behavioral
Applying
Process
Estimation Qs: Example
How much money does Gmail make from ads every year?
Step 1: Ambiguous Information
• Profit or revenue?
• Past year? Or average over history?
• Gmail only? Or include Google Apps?
48. Technical Skills
Estimation Qs: Example
How much money does Gmail make from ads every year?
Process
Applying
Behavioral
Step 2: Outline Your Approach
(# of users)
x
(# clicks / year)
x
( $ / click )
49. Technical Skills
Estimation Qs: Example
How much money does Gmail make from ads every year?
Process
Applying
Behavioral
Step 3: Break down components
Estimate # of Gmail users in the US
1. Assume 300 million people in the US.
–
–
Exclude 0 - 12 years old and 65 - 75 years old
~ 200 million
2. Assume 80% of people use email
3. 80% of those have non-work account
… and so on …
50. Technical Skills
Behavioral
Applying
Process
Estimation Qs: Example
How much money does Gmail make from ads every year?
Step 4: Validate Numbers
• Could revenue be $5 billion?
• No, because…
– Google’s annual revenue is ~$40 billion
– $16 / US citizen (not just Gmail users)
52. Technical
Knowledge & Trivia Questions
• Not key focus at “elite” tech companies.
Estimation
– If asked, tends to focus more on DS
knowledge than language knowledge
• If you don’t know, try to deduce the
answer
Product Design
– How would language designer do it? etc
McDowell | CareerCup.com
53. Technical
Estimation
Product Design
Coding & Algorithm Questions
1. Understand the question
– Clarify, remember key details, etc.
2. Draw an example
–
“Sufficiently interesting”
3. Talk out loud
4. Analyze
– Does it work? What’s the big O time / space?
– Do YOU understand it?
If you’ve heard a
5. Code (SLOWLY)
question before,
6. Test + fix (CAREFULLY)
admit it.
McDowell | CareerCup.com
54. Technical
Estimation
What does a “good coder” do?
• Be methodical. Don’t try to rush.
• Don’t code if you don’t understand
• Reasonably Bug Free
–
–
Thorough testing (and careful fixing)
Check for error conditions
Product Design
• Clean coding
–
–
–
Use other functions
Good use of data structures (define own if useful)
Concise and readable
McDowell | CareerCup.com
55. Product Design
Estimation
Technical
Whiteboard Coding Tips
Code in the FAR top left corner
Write small & straight
Pseudocode if you’d like
Use arrows to insert new code snippets
Use “good” variable names, then
abbreviate
• “Breadth-First” Coding
•
•
•
•
•
McDowell | CareerCup.com
56. Technical
“Breadth-First” Coding
• Divide problems into sub-components
• Ex: Ransom Note
– Write as one big function?
– OR… modularize!
Product Design
Estimation
– Modularize & Structure
McDowell | CareerCup.com
62. Technical
Estimation
Product Design
“Breath-First” Coding
•
“Depth-First” Coding (One big function)
– Messy
– Time consuming
– Poor coding style
•
“Breadth-First” Coding (Modularized)
–
–
–
–
–
“Finishes” algorithm immediately
Often allows you to skip details
Easier to test & fix issues
Demonstrates good coding style
Keeps YOU organized
McDowell | CareerCup.com
63. Technical
Estimation
Common Mistakes
•
•
Ignoring information given
Not using examples
– To design algorithms
– While writing code
•
“Pushing through” code when confused
Product Design
– Incoherent thoughts -> incoherent code
•
•
Diving into code too quickly
The details:
– Off-by-one, < vs <=, division (and any math)
McDowell | CareerCup.com
64. Technical
Types of Interview Questions
Object Oriented Design
System Design
“Reverse a Linked
List”
“Design a Parking
Lot”
“Design a
Web Crawler”
Product Design
Estimation
Coding & Algorithms
McDowell | CareerCup.com
65. Technical
Types of Interview Questions
Coding & Algorithms
Object Oriented Design
Estimation
Pattern Matching
Simplify & Generalize
Product Design
Base Case & Build
Data Structure
Brainstorm
McDowell | CareerCup.com
System Design
66. Technical
Algorithm Qs: Pattern Matching
Coding & Algorithms
Estimation
Pattern Matching
Simplify & Generalize
Product Design
Base Case & Build
Data Structure
Brainstorm
Object Oriented Design
System Design
Q: Write code to reverse the order of words
in a sentence.
“dogs are cute”
“cute are dogs”
Similar to: reverse characters in a string.
“dogs are cute”
“etuc era sgod”
A: Reverse full string, then reverse each
word.
McDowell | CareerCup.com
67. Technical
Algorithm Qs: Simplify & Generalize
Coding & Algorithms
Estimation
Pattern Matching
Simplify & Generalize
Product Design
Base Case & Build
Data Structure
Brainstorm
Object Oriented Design
System Design
Q: Design algorithm to figure out if you can
build a ransom note (array of strings) from a
magazine (array of strings).
Simplify: what if we used characters instead
of strings?
Build array of character frequencies.
Generalize: how we can extend answer to
words?
A: Build hashtable from word to frequency.
McDowell | CareerCup.com
68. Technical
Algorithm Qs: Base Case & Build
Coding & Algorithms
Estimation
Pattern Matching
Simplify & Generalize
Product Design
Base Case & Build
Data Structure
Brainstorm
Object Oriented Design
System Design
Q: Design algorithm to print subsets of set.
{a, b, c}
{}, {a}, {b}, {c}, {a, b},
{a, c}, {b, c}, {a, b, c}
S({})
S({a})
S({a, b})
S({a, b, c})
{}
{}, {a}
{}, {a}, {b}, {a, b}
?
A: Build S(n) by cloning S(n-1) and adding n
to the cloned sets.
McDowell | CareerCup.com
69. Technical
Algorithm Qs: Data Structure Brainstorm
Coding & Algorithms
Estimation
Pattern Matching
Simplify & Generalize
Product Design
Base Case & Build
Data Structure
Brainstorm
Object Oriented Design
System Design
Q: There are 10^10 possible phone #s.
Explain how you could efficiently implement
assignSpecificNum(num) and
assignAnyAvailableNum().
Array (sorted)? Too slow to remove num.
Linked list? Too slow to find specific num.
Hash table? Can’t iterate through free nums.
Tree? Ah-ha!
A: Store free #s in BST. Remove when taken.
McDowell | CareerCup.com
70. Technical
How To Solve Algorithm Questions
Coding & Algorithms
Estimation
Pattern Matching
Simplify & Generalize
Product Design
Base Case & Build
Data Structure
Brainstorm
Object Oriented Design
System Design
Compare to similar problems.
Solve first for a simplified / tweaked problem.
Solve for n = 1, and build solution for n = 2.
Try to apply data structure to solve problem.
McDowell | CareerCup.com
71. Technical
Object Oriented Design
Estimation
Coding & Algorithms
Object Oriented Design
System Design
Handle Ambiguity
What about the question is ambiguous?
Design the Core Objects
What are the main objects in the system?
Product Design
Analyze Relationships
How are the objects related to each other?
Investigate Actions
What are the main operations?
McDowell | CareerCup.com
72. Technical
Object Oriented Design
Product Design
Estimation
Coding & Algorithms
Object Oriented Design
System Design
Handle Ambiguity
Is it a single restaurant, or part of a chain?
How would you
design the data
structures and
objects for a
restaurant?
Design the Core Objects
Guest, Party, Table, Server, Host, …
Analyze Relationships
Server and Host are both Employees…
Investigate Actions
A Party is seated at a Table by a Host…
McDowell | CareerCup.com
73. Technical
System Design
Estimation
Coding & Algorithms
Object Oriented Design
System Design
Handle Ambiguity
What about the question is ambiguous?
Make Believe
Pretend there wasn’t so much data & solve
Product Design
Get Real
Go back to the real problem. What breaks?
Solve Problems
Solve the issues you just found.
McDowell | CareerCup.com
74. Technical
System Design
Product Design
Estimation
Coding & Algorithms
Object Oriented Design
System Design
Handle Ambiguity
Do the words need to be in a specific
order?
Given millions of
documents, find
all documents
which contain a
list of words.
Make Believe
Assume everything can fit on one machine.
Get Real
Must split up data across machines.
Solve Problems
Divide hash table by file or by keyword?
McDowell | CareerCup.com
75. Technical
Whew! All Done!
Coding & Algorithms
Object Oriented Design
System Design
Estimation
Pattern Matching
Simplify & Generalize
<Gulp> This is a lot of
stuff. Do I need to get
everything right?
Product Design
Base Case & Build
Data Structure
Brainstorm
McDowell | CareerCup.com
76. Technical Skills
Behavioral
Applying
Process
Evaluation is RELATIVE,
not absolute.
It’s not about how
quickly you solved
the problem…
<Gulp> This is a lot of
stuff. Do I need to get
everything right?
</Gulp>
… it’s about how quickly
you solved it relative to
other candidates.
McDowell | CareerCup.com
78. Technical Skills
After Your Interview
• Follow-up with your recruiter
Applying
Behavioral
– No response != rejection
• You have no idea how well/poorly you
did.
– Seriously. I know you think you do. But you
don’t.
• Lots of randomness.
Process
– So if you fail, get up and try again.
McDowell | CareerCup.com
80. Technical Skills
Behavioral
Applying
But I hate negotiating!
• Welcome to the club!
• You ARE in demand.
• Your offer will not be revoked.
Is this conversation SO terrible that
you’re willing to give up $1000+**?
Process
** and likely more
McDowell | CareerCup.com
82. Technical Skills
Behavioral
Applying
Closing Advice
•
•
•
•
•
Do projects
Study for your interviews
Chase interviews
… but don’t chase money
If possible, go to an “elite” tech company
– (But don’t stay too long if that’s not what you
want!)
• Check-in on your career.
Process
– Is this what you want to do with your life?
McDowell | CareerCup.com