Cracking the Coding (& PM) Interview Advice and Strategies for Software Engineering and Product Management Interviews McDowell | CareerCup.com July 2013 Gayle Laakmann McDowell Founder / CEO, CareerCup.com Author of Cracking the Coding Interview, Cracking the PM Interview , & The Google Resume
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.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Cracking the Coding (& PM) Interview
Advice and Strategies for Software Engineering and Product Management Interviews
• 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
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
What is a Programmer?
Programmer==
Software Engineer==
Software Developer (Dev)==
Software Design Engineer (SDE)(Microsoft)
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
What is a Programmer?
• Write code (duh)• Architect systems• Plus sometimes:– Write specs– Talk to users– Figure out feature set– Etc
• Communication & Structured Thinking• Ability to understand the user• Creativity• Business instincts / skills
Technical SkillsBehavioralApplying
Process
Product Design Qs: Approach
1. Ask questions to resolve ambiguity2. Understand the user3. Structure the problem4. Solve piece by piece
Technical SkillsBehavioralApplying
Process
Product Design Qs: Example
Step 1: Ask Questions• Adults? Children? Professionals?• Where are they using it?– School, work, etc.
How would you design a calculator for the blind?
Technical SkillsBehavioralApplying
Process
Product Design Qs: Example
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.?
How would you design a calculator for the blind?
Technical SkillsBehavioralApplying
Process
Product Design Qs: Example
Step 3: Structure• Find a structure– Otherwise, you’re just blabbering
• One approach:1. Make list of functions necessary2. Discuss how to do input / output3. Usability for non-blind4. Summary
How would you design a calculator for the blind?
Technical SkillsBehavioralApplying
Process
Product Design Qs: Example
Step 4: Solve!
How would you design a calculator for the blind?
Technical SkillsBehavioralApplying
Process
Estimation Questions
How many tennis balls can fit in an SUV?
How much money does Gmail make from ads every year?
How much do New Yorkers spend on electricity each year?
Technical SkillsBehavioralApplying
Process
Estimation Qs: Why?
• Problem Solving
• Basic Quantitative Skills
Technical SkillsBehavioralApplying
Process
Estimation Qs: How to Approach
1. Ask questions to resolve ambiguity– Don’t make assumptions (yet)
2. Outline / Structure Your Approach3. Break down the components– Assume numbers when necessary– State assumptions explicitly– Round numbers to make your math easier
4. Sanity Check– Do your numbers make sense?
Technical SkillsBehavioralApplying
Process
Estimation Qs: Example
Step 1: Ambiguous Information• Profit or revenue?• Past year? Or average over history?• Gmail only? Or include Google Apps?
How much money does Gmail make from ads every year?
Technical SkillsBehavioralApplying
Process
Estimation Qs: Example
Step 2: Outline Your Approach(# of users)
x(# clicks / year)
x( $ / click )
How much money does Gmail make from ads every year?
Technical SkillsBehavioralApplying
Process
Estimation Qs: Example
Step 3: Break down componentsEstimate # 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 email3. 80% of those have non-work account… and so on …
How much money does Gmail make from ads every year?
Technical SkillsBehavioralApplying
Process
Estimation Qs: Example
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)
How much money does Gmail make from ads every year?
• Not key focus at “elite” tech companies.– If asked, tends to focus more on DS
knowledge than language knowledge
• If you don’t know, try to deduce the answer– How would language designer do it? etc
McDowell | CareerCup.com
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 loud4. Analyze– Does it work? What’s the big O time / space? – Do YOU understand it?
5. Code (SLOWLY)6. Test + fix (CAREFULLY)
If you’ve heard a question before,
admit it.
McDowell | CareerCup.com
Technical
Estimation
Product Design
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
• Clean coding– Use other functions– Good use of data structures (define own if useful)– Concise and readable
McDowell | CareerCup.com
Technical
Estimation
Product Design
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
Technical
Estimation
Product Design
“Breadth-First” Coding
• Divide problems into sub-components– Modularize & Structure
• Ex: Ransom Note– Write as one big function?– OR… modularize!
McDowell | CareerCup.com
Technical
Estimation
Product Design
Ex: Ransom Note: “Depth-First” Coding
McDowell | CareerCup.com
Technical
Estimation
Product Design
Ex: Ransom Note: “Breadth-First” Coding
McDowell | CareerCup.com
Technical
Estimation
Product Design
Ex: Ransom Note: “Breadth-First” Coding
McDowell | CareerCup.com
Technical
Estimation
Product Design
Ex: Ransom Note: “Breadth-First” Coding
McDowell | CareerCup.com
Technical
Estimation
Product Design
Ex: Ransom Note: “Breadth-First” Coding
McDowell | CareerCup.com
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
Technical
Estimation
Product Design
Common Mistakes
• Ignoring information given• Not using examples– To design algorithms– While writing code
A: Build S(n) by cloning S(n-1) and adding n to the cloned sets.
McDowell | CareerCup.com
Technical
Estimation
Product Design
Algorithm Qs: Data Structure Brainstorm
Coding & Algorithms
Pattern Matching
Simplify & Generalize
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
Technical
Estimation
Product Design
Coding & Algorithms
Pattern Matching
Simplify & Generalize
Base Case & Build
Data Structure Brainstorm
Object Oriented Design System Design
How To Solve Algorithm Questions
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
Technical
Estimation
Product Design
Object Oriented Design
Handle AmbiguityWhat about the question is ambiguous?
Design the Core ObjectsWhat are the main objects in the system?
Analyze RelationshipsHow are the objects related to each other?
Investigate ActionsWhat are the main operations?
Coding & Algorithms Object Oriented Design System Design
McDowell | CareerCup.com
Technical
Estimation
Product Design
Coding & Algorithms Object Oriented Design System Design
Object Oriented Design
Handle AmbiguityIs it a single restaurant, or part of a chain?
Design the Core ObjectsGuest, Party, Table, Server, Host, …
Analyze RelationshipsServer and Host are both Employees…
Investigate ActionsA Party is seated at a Table by a Host…
How would you design the data structures and objects for a restaurant?
McDowell | CareerCup.com
Technical
Estimation
Product Design
System Design
Handle AmbiguityWhat about the question is ambiguous?
Make BelievePretend there wasn’t so much data & solve
Get RealGo back to the real problem. What breaks?
Solve ProblemsSolve the issues you just found.
Coding & Algorithms Object Oriented Design System Design
McDowell | CareerCup.com
Technical
Estimation
Product Design
System Design
Handle AmbiguityDo the words need to be in a specific order?
Make BelieveAssume everything can fit on one machine.
Get RealMust split up data across machines.
Solve ProblemsDivide hash table by file or by keyword?
Given millions of documents, find all documents
which contain a list of words.
Coding & Algorithms Object Oriented Design System Design
McDowell | CareerCup.com
Technical
Estimation
Product Design
Whew! All Done!
<Gulp> This is a lot of stuff. Do I need to get
everything right?
Coding & Algorithms
Pattern Matching
Simplify & Generalize
Base Case & Build
Data Structure Brainstorm
Object Oriented Design System Design
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
<Gulp> This is a lot of stuff. Do I need to get
everything right?
</Gulp>
Evaluation is RELATIVE, not absolute.
… it’s about how quickly you solved it relative to
other candidates.
It’s not about how quickly you solved the problem…
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
So RELAX!Interviews are supposed to be hard!
Everyone makes mistakes. Everyone!
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
After Your Interview
• Follow-up with your recruiter – 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.– So if you fail, get up and try again.
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
Negotiation
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
But I hate negotiating!
• Welcome to the club!• You ARE in demand.• Your offer will not be revoked.
Is this conversation SO terrible thatyou’re willing to give up $1000+**?
** and likely more
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
Negotiation
• Most->least negotiable (generally)1. Signing bonus/relocation2. Stock3. Salary4. Other benefits
• Easier if you have another offer• Counter-offer• What matters to you?
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
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.– Is this what you want to do with your life?
McDowell | CareerCup.com
Technical SkillsBehavioralApplying
Process
Other ResourcesCareerCup.com• Interview Videos• Resume Review• Mock Interviews