SlideShare une entreprise Scribd logo
1  sur  81
Télécharger pour lire hors ligne
GayleL.McDowell | Founder/ CEO
gayle in/gaylemcdgayle
Cracking the Facebook
Coding Interview
I <3 Facebook!
CareerCup
Why am I here?
00
gayle in/gaylemcdgayleGayle Laakmann McDowell 3
Why wouldFacebookprepyou?!?
Be more
comfortable
Be more prepared
Take out
the mystery
Avoid common
mistakes
gayle in/gaylemcdgayleGayle Laakmann McDowell 4
Hi! I’m Gayle LaakmannMcDowell
Author Interview Coach Interview Consulting
<dev> </dev>
(CS) (MBA)
Gayle Laakmann McDowell 5gayle in/gaylemcdgayle
Yes! Slidesare online!
Gayle.com
 Click “Events”
 Ctrl-F for “Facebook”
What to Expect
gayle in/gaylemcdgayleGayle Laakmann McDowell 7
A Typical**Process(**notuniversal!Askyourrecruiter)
Phone Onsite HiringCommittee & Decision
½ Behavioral
½ Algo / Coding
Design
Algo / Coding
Algo / Coding
Algo / Coding
gayle in/gaylemcdgayle 8
z
Gayle Laakmann McDowell
Typical
Coding
Interview
5 Minutes
Questions FORInterviewer
35 Minutes
Question #1 Question#2
5 Minutes
Prior Experience
gayle in/gaylemcdgayle 9
z
Gayle Laakmann McDowell
Typical
Design
Interview
5 Minutes
Questions FORInterviewer
35 Minutes
Question#1
5 Minutes
Prior Experience
Behavioral
Questions
The soft squishy stuff.
02
gayle in/gaylemcdgayleGayle Laakmann McDowell 11
The Pitch /Resume Walk-Through
• Showsof success
• Prompt the
interviewer
• Hobbies
I’masoftwareengineerat...
Mybackground’sinCS.
IstudiedatUPennandthen…
Atmycurrentcompany,I…
OutsideofworkI…
Gayle Laakmann McDowell 12gayle in/gaylemcdgayle
Your Past Work
3+ Projects
 Hard / cool
 You werecentral
 Technical depth
All Past Work
 TECHNICAL:Challenges,
architecture, tradeoffs,
successes, motivations
 SOFT:Teamwork, leadership,
conflicts, etc
What did YOU do?
What would you do differently?
gayle in/gaylemcdgayle 13
z
Gayle Laakmann McDowell
What
about
YOU?
Be PASSIONATE
Be KNOWLEDGEABLE
Be a GOOD TEAMMATE
Design Questions
Big, meaty problems
03
gayle in/gaylemcdgayle 15
z
Gayle Laakmann McDowell
How
To
Approach
W
W
Y
D
A
W
hat
ould
ou
o
t
ork
gayle in/gaylemcdgayle 16
z
Gayle Laakmann McDowell
How
To
Approach
S
K
I
R
cope
eycomponents
dentify issues
epair
gayle in/gaylemcdgayle 17
z
Gayle Laakmann McDowell
How
To
Approach
① Scope the Problem
 Askquestions
 Make appropriateassumptions
② Define Key Components
 Can besomewhatnaïve
③ Identify Issues
 Bottlenecks,tradeoffs
④ Repair & Redesign
Breadth-first,notdepth-first
Gayle Laakmann McDowell 18gayle in/gaylemcdgayle
ExampleQuestion
Gayle Laakmann McDowell 19gayle in/gaylemcdgayle
Design sketch
Frontend
Backend
Data store
logger
Gayle Laakmann McDowell 20gayle in/gaylemcdgayle
Collaborativediscussionthat you’re driving!
DRIVE
 Leadtheprocess
 Be openaboutissues
TEAMWORK
 Be opentofeedback
 Tweak asnecessary
Usethewhiteboard!
gayle in/gaylemcdgayle 21
z
Gayle Laakmann McDowell
How
To
Prepare
Read about design of major companies
 THINK, don’t memorize!
Know key concepts
 Tasks, sharding, caches.
 Web stack, REST, etc
Practice back-of-the-envelope
calculations
Algorithm
Questions
Things that make you think
04
Gayle Laakmann McDowell 23gayle in/gaylemcdgayle
Why?
Analytical skills
How you think
Make tradeoffs
Pushthrough hard
problems
Communication
Strong CS fundamentals
gayle in/gaylemcdgayleGayle Laakmann McDowell 24
Essential Knowledge
Data Structures Algorithms Concepts
ArrayLists Merge Sort BigO Time
Hash Tables QuickSort BigO Space
Trees(+Tries) & Graphs Breadth-FirstSearch Recursion
LinkedLists Depth-FirstSearch Memoization/ Dynamic
Programming
Stacks/ Queues BinarySearch
Heaps
gayle in/gaylemcdgayleGayle Laakmann McDowell 25
Preparation
MASTER Big O
ImplementDS/Algorithms
Practicewith interview questions
Code on paper/whiteboard
Mock interviews
PUSHYOURSELF!
A Crash Course in Big O
Just getting your feet wet
gayle in/gaylemcdgayleGayle Laakmann McDowell 27
Basicfor loop
Print0 throughN
Runtime?
 O(N)
gayle in/gaylemcdgayleGayle Laakmann McDowell 28
Two loops
Printevens, thenodds
Runtime?O(N)
gayle in/gaylemcdgayleGayle Laakmann McDowell 29
Basicfor loop
Printpairs from two arrays
Runtime?
 O(A*B)
gayle in/gaylemcdgayleGayle Laakmann McDowell 30
Basicfor loop
Printordered pairs
Runtime?
 O(N2)
j : 0  N
i:0N
x x x x x x
x x x x x
x x x x
x x x
x x
x
gayle in/gaylemcdgayleGayle Laakmann McDowell 31
Okay now thingsare getting tougher!
gayle in/gaylemcdgayleGayle Laakmann McDowell 32
Okay now thingsare getting tougher!
Step 1: O(P)
 P = numberof people
Step 2: O(P * Y)
 Y = max life span
Step 3: O(L)
 L = last death year
O(P + P * Y + L)  O(P * Y + L)
gayle in/gaylemcdgayleGayle Laakmann McDowell 33
Validate
Validate
Runtime?
 undefined
gayle in/gaylemcdgayleGayle Laakmann McDowell 34
Fibonacci
Runtime?
Eeek. Recursion?
gayle in/gaylemcdgayleGayle Laakmann McDowell 35
Fibonacci
Eeek. Recursion?
• Height of N
• Each level doubles # nodes
•  O(2N) time ***
•  O(N) space
Actuallyslightlylessforcomplexmathreasons.
gayle in/gaylemcdgayleGayle Laakmann McDowell 36
Fibonacci, part 2
Runtime?
Eeek. Recursion?
• Height of N
• Each level has <=2nodes
•  O(N) time
•  O(N) space
gayle in/gaylemcdgayleGayle Laakmann McDowell 37
Reminders
Drop constants
Don’t drop non-constants
Differentvariables
Avoid ‘n’
Add vs. Multiply
Recursion call tree
Solving Algorithms
How to… attempt to solve a hard problem
gayle in/gaylemcdgayle 39
z
Gayle Laakmann McDowell
What
is NOT
expected
To know the answers
To solve immediately
To code perfectly
(It’snice.Itjustdoesn’t
happen*.)
*Okayfine.Ithappenedonce,in2000+hiringpackets.
gayle in/gaylemcdgayle 40
z
Gayle Laakmann McDowell
What
IS
expected
Be excitedabout hard problems
Drive!
 Keep trying when stuck
 More than just “correct”
Pay attention to me!
Write real code
Showmehowyouthink!
gayle in/gaylemcdgayle 41
z
Gayle Laakmann McDowell
How
To
Approach
CrackingTheCodingInterview.com“Resources”
gayle in/gaylemcdgayle 42Gayle Laakmann McDowell
step
Listen (for clues)
Gayle Laakmann McDowell 43gayle in/gaylemcdgayle
What’s the clue?
Anagram server
 Ex: rates ->aster, stare, taser, tears
Clue:why is it on a server?
Key(sorted string) Value (list of words)
aerst rates, aster, stare, taser, tears,
dgo dog, god
acll call
… …
gayle in/gaylemcdgayle 44Gayle Laakmann McDowell
step
Draw an Example
INTERSECTION SIZE: Find #
elementsin common between
two sorted, distinct arrays:
gayle in/gaylemcdgayleGayle Laakmann McDowell 45
Ex:Intersection ofTwo Sorted Arrays
Most people draw somethinglike this:
[1, 12, 15, 19]
[2, 12, 13, 20]
 Toosmall
 Toospecial-case-y
• same size, one commonelement, same index
gayle in/gaylemcdgayleGayle Laakmann McDowell 46
Ex:Intersection ofTwo Sorted Arrays
Better:
[1, 12, 15, 19, 20, 21]
[2, 15, 17, 19, 21, 25, 27]
 Big
 No specialcases
gayle in/gaylemcdgayle 47Gayle Laakmann McDowell
step
Draw an Example
Big Enough
General Purpose
+
gayle in/gaylemcdgayle 48Gayle Laakmann McDowell
step
Brute Force / Naive
Stupid&terribleisokay!
gayle in/gaylemcdgayle 49Gayle Laakmann McDowell
step
Optimize
Walk through brute
force
Look for optimizations
Gayle Laakmann McDowell 50gayle in/gaylemcdgayle
Techniquesto Develop Algorithms
BUD
Space and Time
Do It Yourself
Recursion
Gayle Laakmann McDowell 51gayle in/gaylemcdgayle
(A) Look for BUD
Bottlenecks
Unnecessary work
Duplicated work
Gayle Laakmann McDowell 52gayle in/gaylemcdgayle
What’s the bottleneck?
 Ex: countingthe intersection
[1, 12, 15, 19, 20, 21]
[2, 15, 17, 19, 21, 25, 27]
 Bottleneck:searching
B
Gayle Laakmann McDowell 53gayle in/gaylemcdgayle
What’s unnecessary?
 Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000
 Unnecessary: looking for d
U
Gayle Laakmann McDowell 54gayle in/gaylemcdgayle
What’s unnecessary?
 Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000
 Unnecessary: looking for d
U
Gayle Laakmann McDowell 55gayle in/gaylemcdgayle
What’s duplicated?
 Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000
 Duplicated: c, d pairs
D
Gayle Laakmann McDowell 56gayle in/gaylemcdgayle
What’s duplicated?
 Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000
 Duplicated: c, d pairs
D
c d c3 + d3
… … …
4 31 29855
4 32 32832
4 33 36001
… … …
5 59 205504
5 60 216125
5 61 227106
… … …
Gayle Laakmann McDowell 57gayle in/gaylemcdgayle
What’s duplicated?
 Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000
 Duplicated: c, d pairs
D
c3 + d3 (c, d)
… …
29855 (4, 31)
32832 (4, 32),(18, 30)
36001 (4, 33)
… …
205504 (5, 59)
216125 (5, 60),(45, 50)
227106 (5, 61)
… …
Gayle Laakmann McDowell 58gayle in/gaylemcdgayle
What’s duplicated?
 Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000
D
Gayle Laakmann McDowell 59gayle in/gaylemcdgayle
What’s duplicated?
 Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000
D
Gayle Laakmann McDowell 60gayle in/gaylemcdgayle
(B)Space/TimeTradeoffs
Hashtables & other datastructures
Precomputing
Gayle Laakmann McDowell 61gayle in/gaylemcdgayle
(C)Do it yourself
Findpermutationsof swithinb
gayle in/gaylemcdgayleGayle Laakmann McDowell 62
find abbcd in
b a b c d b a e f d b b a c b d d f a e
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Gayle Laakmann McDowell 63gayle in/gaylemcdgayle
(C)Do it yourself
Findpermutationsof swithinb
 s = abbcd
 b =
Findthem!
 … now how didyou actuallydoit?
b a b c d b a e f d b b a c b d d f a e
Gayle Laakmann McDowell 64gayle in/gaylemcdgayle
(D)Recursion
 Use, but don’t cling to, recursion
“instinct”
 Trybottom-up
 “Backtracking”
 Draw call-tree
 Derive runtime
 Find repeated subproblems
 Subsets of a set
 {} {}
 {a}{},{a}
 {a,b} {},{a},{b},{a,b}
 {a,b, c} …
 Subsets of {S1…Sn-1} +Sn to each
Gayle Laakmann McDowell 65gayle in/gaylemcdgayle
Techniquesto Develop Algorithms
BUD
Space and Time
Do It Yourself
Recursion
gayle in/gaylemcdgayle 66Gayle Laakmann McDowell
step
Walk Through
Know the variables
andwhen they change
gayle in/gaylemcdgayle 67Gayle Laakmann McDowell
step
Write Beautiful Code
Gayle Laakmann McDowell 68gayle in/gaylemcdgayle
How toWrite WhiteboardCode
Write straight
Top-leftcorner
Use arrows if needed
Error cases
Good style
Modularize (upfront!)
Languagechoiceisuptoyou!
Gayle Laakmann McDowell 69gayle in/gaylemcdgayle
Error Cases
Good to check errors / boundaries!
But consider the time…
gayle in/gaylemcdgayleGayle Laakmann McDowell 70
Good Style
Spacing, line breaks, variable names
Gayle Laakmann McDowell 71gayle in/gaylemcdgayle
Language Choice
Java, Objective C, etc:Abbreviate
Python, Ruby, JS,etc: Carefulwithbuilt-infunctions
gayle in/gaylemcdgayleGayle Laakmann McDowell 72
Modularization
Gayle Laakmann McDowell 73gayle in/gaylemcdgayle
Modularize(Upfront!)
I’ve learned
nothing.
gayle in/gaylemcdgayle 74Gayle Laakmann McDowell
step
Testing
FIRST Analyze
 What’s it doing? Why?
 Anything that looks weird?
 Errorhot spots
THEN use test cases
 Small test cases
 Edge cases
 Biggertest cases
BUT…
 Test code, notalgorithm
 Think as you test
 Think before you fix
Find permutationsof s withinb:
s = abbc
b = babcabbacaabcbabcacbb
for (i = 0; i < b.len – s.len; i++) {
if (isPerm(s, b.subs(i, s.len)) …
}
gayle in/gaylemcdgayle 75
z
Gayle Laakmann McDowell
How
To
Approach
CrackingTheCodingInterview.com“Resources”
Questions for Your
Interviewer
What do you want to know?
05
Gayle Laakmann McDowell 77gayle in/gaylemcdgayle
Prepare some questions
What’s made you
happy / unhappy?
What are your goals?
Culture& work style
Career paths
Technology
Interviewer’s
experience
Final Thoughts
And questions
06
gayle in/gaylemcdgayle 79
z
Gayle Laakmann McDowell
It’s done
for a
reason!
Be agreat teammate.
Be a great engineer.
Gayle Laakmann McDowell 80gayle in/gaylemcdgayle
Butwait, there’s onemore thing...
READY? Follow up with your recruiter to schedule your next steps.
JOB POSTINGS: facebook.com/careers/teams/engineering
SLIDES? Gayle.com -> Events -> search “Facebook”
gayle in/gaylemcdgayleGayle Laakmann McDowell 81
Other Resources
Gayle.com
CareerCup.com
CrackingThe
CodingInterview.com
Or, follow me online
• facebook.com/gayle
• twitter.com/gayle
• gayle.com
• gayle@gayle.com
• quora.com

Contenu connexe

Tendances

Advancing your data science career
Advancing your data science careerAdvancing your data science career
Advancing your data science careerAlexey Grigorev
 
Our Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doOur Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doMetehan Çetinkaya
 
Using Tags & Taxonomies to super charge your eCommerce SEO
Using Tags & Taxonomies to super charge your eCommerce SEOUsing Tags & Taxonomies to super charge your eCommerce SEO
Using Tags & Taxonomies to super charge your eCommerce SEOMichael King
 
Introduction to google hacking database
Introduction to google hacking databaseIntroduction to google hacking database
Introduction to google hacking databaseimthebeginner
 
Query Classification on Steroids with BERT
Query Classification on Steroids with BERTQuery Classification on Steroids with BERT
Query Classification on Steroids with BERTHamlet Batista
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsFrederic Descamps
 
Hernan Ochoa - WCE Internals [RootedCON 2011]
Hernan Ochoa - WCE Internals [RootedCON 2011]Hernan Ochoa - WCE Internals [RootedCON 2011]
Hernan Ochoa - WCE Internals [RootedCON 2011]RootedCON
 
Indexes: The neglected performance all rounder
Indexes: The neglected performance all rounderIndexes: The neglected performance all rounder
Indexes: The neglected performance all rounderMarkus Winand
 
Goodbye SEO fck ups! Learn to set an SEO Quality Assurance Framework
Goodbye SEO fck ups! Learn to set an SEO Quality Assurance FrameworkGoodbye SEO fck ups! Learn to set an SEO Quality Assurance Framework
Goodbye SEO fck ups! Learn to set an SEO Quality Assurance FrameworkAleyda Solís
 
AlphaGo 알고리즘 요약
AlphaGo 알고리즘 요약AlphaGo 알고리즘 요약
AlphaGo 알고리즘 요약Jooyoul Lee
 
Optane DC Persistent Memory(DCPMM) 성능 테스트
Optane DC Persistent Memory(DCPMM) 성능 테스트Optane DC Persistent Memory(DCPMM) 성능 테스트
Optane DC Persistent Memory(DCPMM) 성능 테스트SANG WON PARK
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016Frans Rosén
 
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & ProfitsWeaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & ProfitsHarsh Bothra
 
Helpful logging with python
Helpful logging with pythonHelpful logging with python
Helpful logging with pythonroskakori
 
EntitySearchbrighton2022.pptx
EntitySearchbrighton2022.pptxEntitySearchbrighton2022.pptx
EntitySearchbrighton2022.pptxBenu Aggarwal
 
XACML for Developers - Updates, New Tools, & Patterns for the Eager #IAM Deve...
XACML for Developers - Updates, New Tools, & Patterns for the Eager #IAM Deve...XACML for Developers - Updates, New Tools, & Patterns for the Eager #IAM Deve...
XACML for Developers - Updates, New Tools, & Patterns for the Eager #IAM Deve...David Brossard
 
Tips and Tricks of Toad for Oracle 10.6
Tips and Tricks of Toad for Oracle 10.6Tips and Tricks of Toad for Oracle 10.6
Tips and Tricks of Toad for Oracle 10.6Dsunte Wilson
 

Tendances (20)

Advancing your data science career
Advancing your data science careerAdvancing your data science career
Advancing your data science career
 
Our Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doOur Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.do
 
Using Tags & Taxonomies to super charge your eCommerce SEO
Using Tags & Taxonomies to super charge your eCommerce SEOUsing Tags & Taxonomies to super charge your eCommerce SEO
Using Tags & Taxonomies to super charge your eCommerce SEO
 
Introduction to google hacking database
Introduction to google hacking databaseIntroduction to google hacking database
Introduction to google hacking database
 
Query Classification on Steroids with BERT
Query Classification on Steroids with BERTQuery Classification on Steroids with BERT
Query Classification on Steroids with BERT
 
ZeroNights 2018 | I <"3 XSS
ZeroNights 2018 | I <"3 XSSZeroNights 2018 | I <"3 XSS
ZeroNights 2018 | I <"3 XSS
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and Histograms
 
Google Dorks and SQL Injection
Google Dorks and SQL InjectionGoogle Dorks and SQL Injection
Google Dorks and SQL Injection
 
Hernan Ochoa - WCE Internals [RootedCON 2011]
Hernan Ochoa - WCE Internals [RootedCON 2011]Hernan Ochoa - WCE Internals [RootedCON 2011]
Hernan Ochoa - WCE Internals [RootedCON 2011]
 
Indexes: The neglected performance all rounder
Indexes: The neglected performance all rounderIndexes: The neglected performance all rounder
Indexes: The neglected performance all rounder
 
Goodbye SEO fck ups! Learn to set an SEO Quality Assurance Framework
Goodbye SEO fck ups! Learn to set an SEO Quality Assurance FrameworkGoodbye SEO fck ups! Learn to set an SEO Quality Assurance Framework
Goodbye SEO fck ups! Learn to set an SEO Quality Assurance Framework
 
AlphaGo 알고리즘 요약
AlphaGo 알고리즘 요약AlphaGo 알고리즘 요약
AlphaGo 알고리즘 요약
 
Optane DC Persistent Memory(DCPMM) 성능 테스트
Optane DC Persistent Memory(DCPMM) 성능 테스트Optane DC Persistent Memory(DCPMM) 성능 테스트
Optane DC Persistent Memory(DCPMM) 성능 테스트
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & ProfitsWeaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
 
Helpful logging with python
Helpful logging with pythonHelpful logging with python
Helpful logging with python
 
EntitySearchbrighton2022.pptx
EntitySearchbrighton2022.pptxEntitySearchbrighton2022.pptx
EntitySearchbrighton2022.pptx
 
Google Dorks
Google DorksGoogle Dorks
Google Dorks
 
XACML for Developers - Updates, New Tools, & Patterns for the Eager #IAM Deve...
XACML for Developers - Updates, New Tools, & Patterns for the Eager #IAM Deve...XACML for Developers - Updates, New Tools, & Patterns for the Eager #IAM Deve...
XACML for Developers - Updates, New Tools, & Patterns for the Eager #IAM Deve...
 
Tips and Tricks of Toad for Oracle 10.6
Tips and Tricks of Toad for Oracle 10.6Tips and Tricks of Toad for Oracle 10.6
Tips and Tricks of Toad for Oracle 10.6
 

Similaire à Cracking the Facebook Coding Interview

Cracking the Coding interview (Abbreviated) - aug 2016
Cracking the Coding interview (Abbreviated) - aug 2016Cracking the Coding interview (Abbreviated) - aug 2016
Cracking the Coding interview (Abbreviated) - aug 2016Gayle McDowell
 
Cracking the Coding interview (College)
Cracking the Coding interview (College)Cracking the Coding interview (College)
Cracking the Coding interview (College)Gayle McDowell
 
How to Hire Software Engineers: Best and Worst Practices
How to Hire Software Engineers: Best and Worst PracticesHow to Hire Software Engineers: Best and Worst Practices
How to Hire Software Engineers: Best and Worst PracticesGayle McDowell
 
Prepping Your Engineering Candidates to Reduce Your False Negatives
Prepping Your Engineering Candidates to Reduce Your False NegativesPrepping Your Engineering Candidates to Reduce Your False Negatives
Prepping Your Engineering Candidates to Reduce Your False NegativesGayle McDowell
 
Gayle Laakmann McDowell - Talent42 2015
Gayle Laakmann McDowell - Talent42 2015Gayle Laakmann McDowell - Talent42 2015
Gayle Laakmann McDowell - Talent42 2015Talent42
 
Cracking the PM Interview
Cracking the PM InterviewCracking the PM Interview
Cracking the PM InterviewGayle McDowell
 
Creating the (Im)perfect Developer Interview
Creating the (Im)perfect Developer InterviewCreating the (Im)perfect Developer Interview
Creating the (Im)perfect Developer InterviewGayle McDowell
 
Cracking the Product Manager Interview
Cracking the Product Manager InterviewCracking the Product Manager Interview
Cracking the Product Manager InterviewGayle McDowell
 
Cracking the PM Interview
Cracking the PM InterviewCracking the PM Interview
Cracking the PM InterviewGayle McDowell
 
Fast katz-presentation
Fast katz-presentationFast katz-presentation
Fast katz-presentationDavid Gleich
 

Similaire à Cracking the Facebook Coding Interview (10)

Cracking the Coding interview (Abbreviated) - aug 2016
Cracking the Coding interview (Abbreviated) - aug 2016Cracking the Coding interview (Abbreviated) - aug 2016
Cracking the Coding interview (Abbreviated) - aug 2016
 
Cracking the Coding interview (College)
Cracking the Coding interview (College)Cracking the Coding interview (College)
Cracking the Coding interview (College)
 
How to Hire Software Engineers: Best and Worst Practices
How to Hire Software Engineers: Best and Worst PracticesHow to Hire Software Engineers: Best and Worst Practices
How to Hire Software Engineers: Best and Worst Practices
 
Prepping Your Engineering Candidates to Reduce Your False Negatives
Prepping Your Engineering Candidates to Reduce Your False NegativesPrepping Your Engineering Candidates to Reduce Your False Negatives
Prepping Your Engineering Candidates to Reduce Your False Negatives
 
Gayle Laakmann McDowell - Talent42 2015
Gayle Laakmann McDowell - Talent42 2015Gayle Laakmann McDowell - Talent42 2015
Gayle Laakmann McDowell - Talent42 2015
 
Cracking the PM Interview
Cracking the PM InterviewCracking the PM Interview
Cracking the PM Interview
 
Creating the (Im)perfect Developer Interview
Creating the (Im)perfect Developer InterviewCreating the (Im)perfect Developer Interview
Creating the (Im)perfect Developer Interview
 
Cracking the Product Manager Interview
Cracking the Product Manager InterviewCracking the Product Manager Interview
Cracking the Product Manager Interview
 
Cracking the PM Interview
Cracking the PM InterviewCracking the PM Interview
Cracking the PM Interview
 
Fast katz-presentation
Fast katz-presentationFast katz-presentation
Fast katz-presentation
 

Plus de Gayle McDowell

Architecture of Tech Interviews
Architecture of Tech InterviewsArchitecture of Tech Interviews
Architecture of Tech InterviewsGayle McDowell
 
Cracking the Product Manager Interview
Cracking the Product Manager InterviewCracking the Product Manager Interview
Cracking the Product Manager InterviewGayle McDowell
 
Cracking the Interview Skills (Coding, Soft Skills, Product Management) Handouts
Cracking the Interview Skills (Coding, Soft Skills, Product Management) HandoutsCracking the Interview Skills (Coding, Soft Skills, Product Management) Handouts
Cracking the Interview Skills (Coding, Soft Skills, Product Management) HandoutsGayle McDowell
 
Hiring Great Product Managers
Hiring Great Product ManagersHiring Great Product Managers
Hiring Great Product ManagersGayle McDowell
 
Reverse Engineering Engineering Interviewing: How to Be a Great Interviewer
Reverse Engineering Engineering Interviewing: How to Be a Great InterviewerReverse Engineering Engineering Interviewing: How to Be a Great Interviewer
Reverse Engineering Engineering Interviewing: How to Be a Great InterviewerGayle McDowell
 
Transitioning from Engineering to Product Management
Transitioning from Engineering to Product ManagementTransitioning from Engineering to Product Management
Transitioning from Engineering to Product ManagementGayle McDowell
 
Interviewing Great Developers: Reverse Engineering Interview Coaching to Crea...
Interviewing Great Developers: Reverse Engineering Interview Coaching to Crea...Interviewing Great Developers: Reverse Engineering Interview Coaching to Crea...
Interviewing Great Developers: Reverse Engineering Interview Coaching to Crea...Gayle McDowell
 
Cracking the Coding & PM Interview (Jan 2014)
Cracking the Coding & PM Interview (Jan 2014)Cracking the Coding & PM Interview (Jan 2014)
Cracking the Coding & PM Interview (Jan 2014)Gayle McDowell
 

Plus de Gayle McDowell (8)

Architecture of Tech Interviews
Architecture of Tech InterviewsArchitecture of Tech Interviews
Architecture of Tech Interviews
 
Cracking the Product Manager Interview
Cracking the Product Manager InterviewCracking the Product Manager Interview
Cracking the Product Manager Interview
 
Cracking the Interview Skills (Coding, Soft Skills, Product Management) Handouts
Cracking the Interview Skills (Coding, Soft Skills, Product Management) HandoutsCracking the Interview Skills (Coding, Soft Skills, Product Management) Handouts
Cracking the Interview Skills (Coding, Soft Skills, Product Management) Handouts
 
Hiring Great Product Managers
Hiring Great Product ManagersHiring Great Product Managers
Hiring Great Product Managers
 
Reverse Engineering Engineering Interviewing: How to Be a Great Interviewer
Reverse Engineering Engineering Interviewing: How to Be a Great InterviewerReverse Engineering Engineering Interviewing: How to Be a Great Interviewer
Reverse Engineering Engineering Interviewing: How to Be a Great Interviewer
 
Transitioning from Engineering to Product Management
Transitioning from Engineering to Product ManagementTransitioning from Engineering to Product Management
Transitioning from Engineering to Product Management
 
Interviewing Great Developers: Reverse Engineering Interview Coaching to Crea...
Interviewing Great Developers: Reverse Engineering Interview Coaching to Crea...Interviewing Great Developers: Reverse Engineering Interview Coaching to Crea...
Interviewing Great Developers: Reverse Engineering Interview Coaching to Crea...
 
Cracking the Coding & PM Interview (Jan 2014)
Cracking the Coding & PM Interview (Jan 2014)Cracking the Coding & PM Interview (Jan 2014)
Cracking the Coding & PM Interview (Jan 2014)
 

Dernier

Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 

Dernier (20)

Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 

Cracking the Facebook Coding Interview

  • 1. GayleL.McDowell | Founder/ CEO gayle in/gaylemcdgayle Cracking the Facebook Coding Interview I <3 Facebook! CareerCup
  • 2. Why am I here? 00
  • 3. gayle in/gaylemcdgayleGayle Laakmann McDowell 3 Why wouldFacebookprepyou?!? Be more comfortable Be more prepared Take out the mystery Avoid common mistakes
  • 4. gayle in/gaylemcdgayleGayle Laakmann McDowell 4 Hi! I’m Gayle LaakmannMcDowell Author Interview Coach Interview Consulting <dev> </dev> (CS) (MBA)
  • 5. Gayle Laakmann McDowell 5gayle in/gaylemcdgayle Yes! Slidesare online! Gayle.com  Click “Events”  Ctrl-F for “Facebook”
  • 7. gayle in/gaylemcdgayleGayle Laakmann McDowell 7 A Typical**Process(**notuniversal!Askyourrecruiter) Phone Onsite HiringCommittee & Decision ½ Behavioral ½ Algo / Coding Design Algo / Coding Algo / Coding Algo / Coding
  • 8. gayle in/gaylemcdgayle 8 z Gayle Laakmann McDowell Typical Coding Interview 5 Minutes Questions FORInterviewer 35 Minutes Question #1 Question#2 5 Minutes Prior Experience
  • 9. gayle in/gaylemcdgayle 9 z Gayle Laakmann McDowell Typical Design Interview 5 Minutes Questions FORInterviewer 35 Minutes Question#1 5 Minutes Prior Experience
  • 11. gayle in/gaylemcdgayleGayle Laakmann McDowell 11 The Pitch /Resume Walk-Through • Showsof success • Prompt the interviewer • Hobbies I’masoftwareengineerat... Mybackground’sinCS. IstudiedatUPennandthen… Atmycurrentcompany,I… OutsideofworkI…
  • 12. Gayle Laakmann McDowell 12gayle in/gaylemcdgayle Your Past Work 3+ Projects  Hard / cool  You werecentral  Technical depth All Past Work  TECHNICAL:Challenges, architecture, tradeoffs, successes, motivations  SOFT:Teamwork, leadership, conflicts, etc What did YOU do? What would you do differently?
  • 13. gayle in/gaylemcdgayle 13 z Gayle Laakmann McDowell What about YOU? Be PASSIONATE Be KNOWLEDGEABLE Be a GOOD TEAMMATE
  • 15. gayle in/gaylemcdgayle 15 z Gayle Laakmann McDowell How To Approach W W Y D A W hat ould ou o t ork
  • 16. gayle in/gaylemcdgayle 16 z Gayle Laakmann McDowell How To Approach S K I R cope eycomponents dentify issues epair
  • 17. gayle in/gaylemcdgayle 17 z Gayle Laakmann McDowell How To Approach ① Scope the Problem  Askquestions  Make appropriateassumptions ② Define Key Components  Can besomewhatnaïve ③ Identify Issues  Bottlenecks,tradeoffs ④ Repair & Redesign Breadth-first,notdepth-first
  • 18. Gayle Laakmann McDowell 18gayle in/gaylemcdgayle ExampleQuestion
  • 19. Gayle Laakmann McDowell 19gayle in/gaylemcdgayle Design sketch Frontend Backend Data store logger
  • 20. Gayle Laakmann McDowell 20gayle in/gaylemcdgayle Collaborativediscussionthat you’re driving! DRIVE  Leadtheprocess  Be openaboutissues TEAMWORK  Be opentofeedback  Tweak asnecessary Usethewhiteboard!
  • 21. gayle in/gaylemcdgayle 21 z Gayle Laakmann McDowell How To Prepare Read about design of major companies  THINK, don’t memorize! Know key concepts  Tasks, sharding, caches.  Web stack, REST, etc Practice back-of-the-envelope calculations
  • 23. Gayle Laakmann McDowell 23gayle in/gaylemcdgayle Why? Analytical skills How you think Make tradeoffs Pushthrough hard problems Communication Strong CS fundamentals
  • 24. gayle in/gaylemcdgayleGayle Laakmann McDowell 24 Essential Knowledge Data Structures Algorithms Concepts ArrayLists Merge Sort BigO Time Hash Tables QuickSort BigO Space Trees(+Tries) & Graphs Breadth-FirstSearch Recursion LinkedLists Depth-FirstSearch Memoization/ Dynamic Programming Stacks/ Queues BinarySearch Heaps
  • 25. gayle in/gaylemcdgayleGayle Laakmann McDowell 25 Preparation MASTER Big O ImplementDS/Algorithms Practicewith interview questions Code on paper/whiteboard Mock interviews PUSHYOURSELF!
  • 26. A Crash Course in Big O Just getting your feet wet
  • 27. gayle in/gaylemcdgayleGayle Laakmann McDowell 27 Basicfor loop Print0 throughN Runtime?  O(N)
  • 28. gayle in/gaylemcdgayleGayle Laakmann McDowell 28 Two loops Printevens, thenodds Runtime?O(N)
  • 29. gayle in/gaylemcdgayleGayle Laakmann McDowell 29 Basicfor loop Printpairs from two arrays Runtime?  O(A*B)
  • 30. gayle in/gaylemcdgayleGayle Laakmann McDowell 30 Basicfor loop Printordered pairs Runtime?  O(N2) j : 0  N i:0N x x x x x x x x x x x x x x x x x x x x x
  • 31. gayle in/gaylemcdgayleGayle Laakmann McDowell 31 Okay now thingsare getting tougher!
  • 32. gayle in/gaylemcdgayleGayle Laakmann McDowell 32 Okay now thingsare getting tougher! Step 1: O(P)  P = numberof people Step 2: O(P * Y)  Y = max life span Step 3: O(L)  L = last death year O(P + P * Y + L)  O(P * Y + L)
  • 33. gayle in/gaylemcdgayleGayle Laakmann McDowell 33 Validate Validate Runtime?  undefined
  • 34. gayle in/gaylemcdgayleGayle Laakmann McDowell 34 Fibonacci Runtime? Eeek. Recursion?
  • 35. gayle in/gaylemcdgayleGayle Laakmann McDowell 35 Fibonacci Eeek. Recursion? • Height of N • Each level doubles # nodes •  O(2N) time *** •  O(N) space Actuallyslightlylessforcomplexmathreasons.
  • 36. gayle in/gaylemcdgayleGayle Laakmann McDowell 36 Fibonacci, part 2 Runtime? Eeek. Recursion? • Height of N • Each level has <=2nodes •  O(N) time •  O(N) space
  • 37. gayle in/gaylemcdgayleGayle Laakmann McDowell 37 Reminders Drop constants Don’t drop non-constants Differentvariables Avoid ‘n’ Add vs. Multiply Recursion call tree
  • 38. Solving Algorithms How to… attempt to solve a hard problem
  • 39. gayle in/gaylemcdgayle 39 z Gayle Laakmann McDowell What is NOT expected To know the answers To solve immediately To code perfectly (It’snice.Itjustdoesn’t happen*.) *Okayfine.Ithappenedonce,in2000+hiringpackets.
  • 40. gayle in/gaylemcdgayle 40 z Gayle Laakmann McDowell What IS expected Be excitedabout hard problems Drive!  Keep trying when stuck  More than just “correct” Pay attention to me! Write real code Showmehowyouthink!
  • 41. gayle in/gaylemcdgayle 41 z Gayle Laakmann McDowell How To Approach CrackingTheCodingInterview.com“Resources”
  • 42. gayle in/gaylemcdgayle 42Gayle Laakmann McDowell step Listen (for clues)
  • 43. Gayle Laakmann McDowell 43gayle in/gaylemcdgayle What’s the clue? Anagram server  Ex: rates ->aster, stare, taser, tears Clue:why is it on a server? Key(sorted string) Value (list of words) aerst rates, aster, stare, taser, tears, dgo dog, god acll call … …
  • 44. gayle in/gaylemcdgayle 44Gayle Laakmann McDowell step Draw an Example INTERSECTION SIZE: Find # elementsin common between two sorted, distinct arrays:
  • 45. gayle in/gaylemcdgayleGayle Laakmann McDowell 45 Ex:Intersection ofTwo Sorted Arrays Most people draw somethinglike this: [1, 12, 15, 19] [2, 12, 13, 20]  Toosmall  Toospecial-case-y • same size, one commonelement, same index
  • 46. gayle in/gaylemcdgayleGayle Laakmann McDowell 46 Ex:Intersection ofTwo Sorted Arrays Better: [1, 12, 15, 19, 20, 21] [2, 15, 17, 19, 21, 25, 27]  Big  No specialcases
  • 47. gayle in/gaylemcdgayle 47Gayle Laakmann McDowell step Draw an Example Big Enough General Purpose +
  • 48. gayle in/gaylemcdgayle 48Gayle Laakmann McDowell step Brute Force / Naive Stupid&terribleisokay!
  • 49. gayle in/gaylemcdgayle 49Gayle Laakmann McDowell step Optimize Walk through brute force Look for optimizations
  • 50. Gayle Laakmann McDowell 50gayle in/gaylemcdgayle Techniquesto Develop Algorithms BUD Space and Time Do It Yourself Recursion
  • 51. Gayle Laakmann McDowell 51gayle in/gaylemcdgayle (A) Look for BUD Bottlenecks Unnecessary work Duplicated work
  • 52. Gayle Laakmann McDowell 52gayle in/gaylemcdgayle What’s the bottleneck?  Ex: countingthe intersection [1, 12, 15, 19, 20, 21] [2, 15, 17, 19, 21, 25, 27]  Bottleneck:searching B
  • 53. Gayle Laakmann McDowell 53gayle in/gaylemcdgayle What’s unnecessary?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000  Unnecessary: looking for d U
  • 54. Gayle Laakmann McDowell 54gayle in/gaylemcdgayle What’s unnecessary?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000  Unnecessary: looking for d U
  • 55. Gayle Laakmann McDowell 55gayle in/gaylemcdgayle What’s duplicated?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000  Duplicated: c, d pairs D
  • 56. Gayle Laakmann McDowell 56gayle in/gaylemcdgayle What’s duplicated?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000  Duplicated: c, d pairs D c d c3 + d3 … … … 4 31 29855 4 32 32832 4 33 36001 … … … 5 59 205504 5 60 216125 5 61 227106 … … …
  • 57. Gayle Laakmann McDowell 57gayle in/gaylemcdgayle What’s duplicated?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000  Duplicated: c, d pairs D c3 + d3 (c, d) … … 29855 (4, 31) 32832 (4, 32),(18, 30) 36001 (4, 33) … … 205504 (5, 59) 216125 (5, 60),(45, 50) 227106 (5, 61) … …
  • 58. Gayle Laakmann McDowell 58gayle in/gaylemcdgayle What’s duplicated?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000 D
  • 59. Gayle Laakmann McDowell 59gayle in/gaylemcdgayle What’s duplicated?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000 D
  • 60. Gayle Laakmann McDowell 60gayle in/gaylemcdgayle (B)Space/TimeTradeoffs Hashtables & other datastructures Precomputing
  • 61. Gayle Laakmann McDowell 61gayle in/gaylemcdgayle (C)Do it yourself Findpermutationsof swithinb
  • 62. gayle in/gaylemcdgayleGayle Laakmann McDowell 62 find abbcd in b a b c d b a e f d b b a c b d d f a e 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  • 63. Gayle Laakmann McDowell 63gayle in/gaylemcdgayle (C)Do it yourself Findpermutationsof swithinb  s = abbcd  b = Findthem!  … now how didyou actuallydoit? b a b c d b a e f d b b a c b d d f a e
  • 64. Gayle Laakmann McDowell 64gayle in/gaylemcdgayle (D)Recursion  Use, but don’t cling to, recursion “instinct”  Trybottom-up  “Backtracking”  Draw call-tree  Derive runtime  Find repeated subproblems  Subsets of a set  {} {}  {a}{},{a}  {a,b} {},{a},{b},{a,b}  {a,b, c} …  Subsets of {S1…Sn-1} +Sn to each
  • 65. Gayle Laakmann McDowell 65gayle in/gaylemcdgayle Techniquesto Develop Algorithms BUD Space and Time Do It Yourself Recursion
  • 66. gayle in/gaylemcdgayle 66Gayle Laakmann McDowell step Walk Through Know the variables andwhen they change
  • 67. gayle in/gaylemcdgayle 67Gayle Laakmann McDowell step Write Beautiful Code
  • 68. Gayle Laakmann McDowell 68gayle in/gaylemcdgayle How toWrite WhiteboardCode Write straight Top-leftcorner Use arrows if needed Error cases Good style Modularize (upfront!) Languagechoiceisuptoyou!
  • 69. Gayle Laakmann McDowell 69gayle in/gaylemcdgayle Error Cases Good to check errors / boundaries! But consider the time…
  • 70. gayle in/gaylemcdgayleGayle Laakmann McDowell 70 Good Style Spacing, line breaks, variable names
  • 71. Gayle Laakmann McDowell 71gayle in/gaylemcdgayle Language Choice Java, Objective C, etc:Abbreviate Python, Ruby, JS,etc: Carefulwithbuilt-infunctions
  • 72. gayle in/gaylemcdgayleGayle Laakmann McDowell 72 Modularization
  • 73. Gayle Laakmann McDowell 73gayle in/gaylemcdgayle Modularize(Upfront!) I’ve learned nothing.
  • 74. gayle in/gaylemcdgayle 74Gayle Laakmann McDowell step Testing FIRST Analyze  What’s it doing? Why?  Anything that looks weird?  Errorhot spots THEN use test cases  Small test cases  Edge cases  Biggertest cases BUT…  Test code, notalgorithm  Think as you test  Think before you fix Find permutationsof s withinb: s = abbc b = babcabbacaabcbabcacbb for (i = 0; i < b.len – s.len; i++) { if (isPerm(s, b.subs(i, s.len)) … }
  • 75. gayle in/gaylemcdgayle 75 z Gayle Laakmann McDowell How To Approach CrackingTheCodingInterview.com“Resources”
  • 76. Questions for Your Interviewer What do you want to know? 05
  • 77. Gayle Laakmann McDowell 77gayle in/gaylemcdgayle Prepare some questions What’s made you happy / unhappy? What are your goals? Culture& work style Career paths Technology Interviewer’s experience
  • 79. gayle in/gaylemcdgayle 79 z Gayle Laakmann McDowell It’s done for a reason! Be agreat teammate. Be a great engineer.
  • 80. Gayle Laakmann McDowell 80gayle in/gaylemcdgayle Butwait, there’s onemore thing... READY? Follow up with your recruiter to schedule your next steps. JOB POSTINGS: facebook.com/careers/teams/engineering SLIDES? Gayle.com -> Events -> search “Facebook”
  • 81. gayle in/gaylemcdgayleGayle Laakmann McDowell 81 Other Resources Gayle.com CareerCup.com CrackingThe CodingInterview.com Or, follow me online • facebook.com/gayle • twitter.com/gayle • gayle.com • gayle@gayle.com • quora.com