gayle mcdowell: cracking the coding interview

45
Cracking the Coding Interview Advice and Strategies for Software Engineering Interviews McDowell | NIT Trichy | Feb 2012 CareerCup.com Gayle Laakmann McDowell Founder / CEO, CareerCup.com Author of The Google Resume and Cracking the Coding Interview

Post on 18-Oct-2014

3.816 views

Category:

Education


4 download

DESCRIPTION

Talk video in youtube: http://www.youtube.com/watch?v=rEJzOhC5ZtQ

TRANSCRIPT

Page 1: Gayle McDowell: Cracking the coding interview

Cracking the Coding Interview

Advice and Strategies for Software Engineering Interviews

McDowell | NIT Trichy | Feb 2012 CareerCup.com

Gayle Laakmann McDowellFounder / CEO, CareerCup.com

Author of The Google Resume and Cracking the Coding Interview

Page 2: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

My Background

• Software Engineer @ GOOG, MS & Apple– 3 Years on Google Hiring Committee– Interviewed 150+ candidates

• Founder of CareerCup.com• Author– Cracking the Coding Interview – The Google Resume

Page 3: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Slides Posted Online

posted at:www.technologywoman.com

Click “Speaking Engagements”

Page 4: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Process

Evaluation

Structure

Applying

Experience

Resume

Soft Skills

Preparation

Interview

Tech Skills

Preparation

Interview

Page 5: Gayle McDowell: Cracking the coding interview

Interview Process

McDowell | CareerCup.com

Page 6: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Big Company Evaluation (Coding)

IntelligenceCodingSkills

PersonalityExperience

Testing aptitude, not knowledge

Page 7: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

How You Are Judged

How did you do RELATIVEto other candidates on

the SAME question?

… it’s about how quickly you solved it relative to

other candidates.

It’s not about how quickly you solved the problem…

Page 8: Gayle McDowell: Cracking the coding interview

Resumes & Application Process

McDowell | CareerCup.com

Page 9: Gayle McDowell: Cracking the coding interview

Technical SkillsBehavioralApplying

Process

Indians are at a disadvantage

• Far away– Fewer recruiting opportunities

• Unfamiliar– Recruiters may not understand your

school, GPA, etc

• Language barrier / Cultural differences– Accents, grammar, accidental sexism

• Different / less experience– More emphasis in US on projects

Page 10: Gayle McDowell: Cracking the coding interview

Technical SkillsBehavioralApplying

Process

So what to do?

• Get equivalent experience • Translate GPA & other items• Use good grammar & punctuation– On resumes, cover letters, etc– No abbreviations, no sloppiness

• Be careful about your assumptions– Sexism is not acceptable in the U.S. Ever.

Page 11: Gayle McDowell: Cracking the coding interview

Technical SkillsBehavioralApplying

Process

Cheat Sheet for Indians (Grammar / Writing)

• Space after comma & period. Never before.– WRONG: “Hello .I am Gayle .”– RIGHT: “Hello. I am Gayle.”

• Questions need a question mark– WRONG: “Do you have one.”– RIGHT: “Do you have one?”

• No abbreviations– WRONG: “Ny1 dr?”– RIGHT: “Is anyone there?”

• Commands are rude (use a question)– WRONG: “Send it to me.”– RIGHT: “Would you mind sending it to me?”

Page 12: Gayle McDowell: Cracking the coding interview

Technical SkillsBehavioralApplying

Process

Cheat Sheet for Indians(Gender / Sexism)

• Mr. LastName / Ms. LastName– WRONG: Ms. Gayle– RIGHT: Ms. McDowell– But “Dear Gayle” is perfectly okay in U.S.

• “Guy” / “Guys” is not unisex* in the U.S.– WRONG: “I need to hire a really smart CS guy.”– *Except: “you guys” and “hey guys”

• Don’t assume that people are male / female– (Just don’t use Mr. / Ms. in emails!)

• It is EXTREMELY offensive to comment on someone’s looks– But a great way to get fired / rejected

Page 13: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Cheat Sheet for Indians(Getting Experience)

• Build something!

• Make a kick-ass resume

Don’t waste your summers!

It’s really not that hard.

Page 14: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

How We Review Resumes (U.S.)

1. Pull resume out of giant stack2. Spot-check: company names,

positions, projects, schools.3. Skim bullets to see if you’ve

written real code.

InterviewReject

4. Go to next resume & whine about how many more you have left.

“Glanced at,” not

read.15 – 30 seconds

Page 15: Gayle McDowell: Cracking the coding interview

How CS Resume Should Look (U.S.)

Short (1 – 2 line bullets)

3 – 4 ProjectsCourses & independentFinished or unfinished

List of Technical Skills

Short! Cut the “fluff.”

GPA - TranslatedWe don’t understand

“first class”

One Page Only!Unless > 10 years

exp.

A Real Resume Formatwith organized columns

Focus on Accomplishmentsnot responsibilities

Observe: No Objective!

Objectives / summaries are almost always

useless.

Page 16: Gayle McDowell: Cracking the coding interview

Behavioral Questions

McDowell | CareerCup.com

Page 17: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Communication Tips

• Goals:– Answer the question.– Deliver a *good* answer.– Communicate well.

• Strategies:– Nugget First– S.A.R.: Situation, Action, Result

Page 18: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Preparing for Behavioral Qs

• Create Preparation Grid for ProjectsOS Project Amazon Intern.

Enjoyed

Hated

Most Challenging

Hardest Bug

+ Behavioral Grid [for PM & less tech. roles]

Page 19: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Structure 1: Nugget First

• 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 …

Q: What accomplishment are you most proud of?

Page 20: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Structure 2: S.A.R.

ituationctionesult

SAR

What was the issue?

What did you do about it?

What was the impact?

Page 21: Gayle McDowell: Cracking the coding interview

Technical SkillsInterview Prep

McDowell | CareerCup.com

Page 22: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

How to study

• Study the basics– Complex algorithms generally unnecessary.

• Practice solving questions– Don’t memorize!– See: CtCI & CareerCup.com

• Push yourself! • Write code on paper

Page 23: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Data Structures

• How to implement• When to use (pros / cons)

Linked Lists Stacks Queues

Trees Tries Graphs

Vectors Heaps Hashtables

Page 24: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Algorithms

• Implementation• Space vs. Time

ComplexityQuick Sort Merge Sort

Tree Insert / Find Binary Search

Breadth-First Search

Depth-First Search

Page 25: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Concepts

• Not just a concept – know how to code!

Threading System Design & Scalability

MemoryManagement

Recursion Probability + Combinatorics Bit Manipulation

Page 26: Gayle McDowell: Cracking the coding interview

Technical SkillsMastering the Interview

McDowell | CareerCup.com

Page 27: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Technical Questions

1. Ask Questions!– Questions are more ambiguous than they appear

2. Talk out loud– Show us how you think

3. Think critically– Does your algorithm really work? What’s the space

and time complexity?

4. Code slowly and methodically– It’s not a race

5. Test your code– And make CAREFUL fixes.

Page 28: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

What does a “good coder” do?

• Be methodical. Don’t try to rush.• 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

Page 29: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Types of Interview Questions

Coding & Algorithms

Object Oriented Design System Design

“Reverse a Linked List”

“Design a Parking Lot”

“Design a Web Crawler”

Page 30: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Types of Interview QuestionsCoding & Algorithms

Pattern Matching

Simplify & Generalize

Base Case & Build

Data Structure Brainstorm

Object Orient

ed Design

System

Design

Page 31: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Algorithm Qs: Pattern Matching

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.

Coding & Algorithms

Pattern Matching

Simplify & Generalize

Base Case & Build

Data Structure Brainstorm

Object Orient

ed Design

System

Design

Page 32: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Algorithm Qs: Simplify & GeneralizeCoding & Algorithms

Pattern Matching

Simplify & Generalize

Base Case & Build

Data Structure Brainstorm

Object Orient

ed 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.

Page 33: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Algorithm Qs: Base Case & BuildCoding & Algorithms

Pattern Matching

Simplify & Generalize

Base Case & Build

Data Structure Brainstorm

Object Orient

ed 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}) {}, {a}S({a, b}) {}, {a}, {b}, {a, b}S({a, b, c}) ?

A: Build S(n) by cloning S(n-1) and adding n to the cloned sets.

Page 34: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Algorithm Qs: Data Structure BrainstormCoding & Algorithms

Pattern Matching

Simplify & Generalize

Base Case & Build

Data Structure Brainstorm

Object Orient

ed 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.

Page 35: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Coding & Algorithms

Pattern Matching

Simplify & Generalize

Base Case & Build

Data Structure Brainstorm

Object Orient

ed 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.

Page 36: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

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

Page 37: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

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?

Page 38: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

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

Page 39: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

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

Page 40: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

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 Orient

ed Design

System

Design

Page 41: Gayle McDowell: Cracking the coding interview

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…

Page 42: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

So RELAX!Interviews are supposed to be hard!

Everyone makes mistakes. Everyone!

Page 43: Gayle McDowell: Cracking the coding interview

Final Thoughts

McDowell | CareerCup.com

Page 44: Gayle McDowell: Cracking the coding interview

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.

Page 45: Gayle McDowell: Cracking the coding interview

McDowell | CareerCup.com

Technical SkillsBehavioralApplying

Process

Other ResourcesSold TodaySigned (just ask!)

CareerCup.com• Interview Videos• iPhone App• Resume Review• Mock Interviews

today

Rs. 400

5 stars!

Or, stalk me online at…• twitter.com/gayle• facebook.com/gayle• technologywoman.com• [email protected]