SlideShare a Scribd company logo
1 of 81
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

More Related Content

What's hot

Making Magento Magnificent for Marketing - Brighton SEO Spring 2023.pdf
Making Magento Magnificent for Marketing - Brighton SEO Spring 2023.pdfMaking Magento Magnificent for Marketing - Brighton SEO Spring 2023.pdf
Making Magento Magnificent for Marketing - Brighton SEO Spring 2023.pdfPushON Ltd
 
300 best boolean strings - table of contents
300 best boolean strings - table of contents300 best boolean strings - table of contents
300 best boolean strings - table of contentsIrina Shamaeva
 
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...MongoDB
 
Become a Ninja Recruiter: Advanced Boolean Search | Talent Connect London 2014
Become a Ninja Recruiter: Advanced Boolean Search | Talent Connect London 2014Become a Ninja Recruiter: Advanced Boolean Search | Talent Connect London 2014
Become a Ninja Recruiter: Advanced Boolean Search | Talent Connect London 2014LinkedIn Talent Solutions
 
MongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB
 
How to Make eCommerce Product Pages Content Unique
How to Make eCommerce Product Pages Content  UniqueHow to Make eCommerce Product Pages Content  Unique
How to Make eCommerce Product Pages Content UniqueKristina Azarenko
 
Intent-Based International Keyword Research - International Search Summit, Ba...
Intent-Based International Keyword Research - International Search Summit, Ba...Intent-Based International Keyword Research - International Search Summit, Ba...
Intent-Based International Keyword Research - International Search Summit, Ba...LazarinaStoyanova
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
XPath for web scraping
XPath for web scrapingXPath for web scraping
XPath for web scrapingScrapinghub
 
Entrepreneurial Operating System - A keynote
Entrepreneurial Operating System - A keynoteEntrepreneurial Operating System - A keynote
Entrepreneurial Operating System - A keynoteScott Patchin
 
How to Get People to Respond to Your Recruiting Emails & Messages
How to Get People to Respond to Your Recruiting Emails & MessagesHow to Get People to Respond to Your Recruiting Emails & Messages
How to Get People to Respond to Your Recruiting Emails & MessagesGlen Cathey
 
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
 
Revisão AP1 Construção de Páginas Web - CEDERJ
Revisão AP1 Construção de Páginas Web - CEDERJRevisão AP1 Construção de Páginas Web - CEDERJ
Revisão AP1 Construção de Páginas Web - CEDERJDeyvid Nascimento
 
APEX Interactive Grid API Essentials: The Stuff You Will Really Use
APEX Interactive Grid API Essentials:  The Stuff You Will Really UseAPEX Interactive Grid API Essentials:  The Stuff You Will Really Use
APEX Interactive Grid API Essentials: The Stuff You Will Really UseKaren Cannell
 
HELP! I've Been Hit By An Algorithm Update - Jess Maloney - BrightonSEO Apri...
HELP! I've Been Hit By An Algorithm Update - Jess Maloney - BrightonSEO  Apri...HELP! I've Been Hit By An Algorithm Update - Jess Maloney - BrightonSEO  Apri...
HELP! I've Been Hit By An Algorithm Update - Jess Maloney - BrightonSEO Apri...Jessica Maloney
 
TCS: MORE Freakishly Effective Marketing Hacks From Traffic & Conversion Summit
TCS: MORE Freakishly Effective Marketing Hacks From Traffic & Conversion SummitTCS: MORE Freakishly Effective Marketing Hacks From Traffic & Conversion Summit
TCS: MORE Freakishly Effective Marketing Hacks From Traffic & Conversion SummitRoland Frasier
 
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)都元ダイスケ Miyamoto
 

What's hot (20)

Making Magento Magnificent for Marketing - Brighton SEO Spring 2023.pdf
Making Magento Magnificent for Marketing - Brighton SEO Spring 2023.pdfMaking Magento Magnificent for Marketing - Brighton SEO Spring 2023.pdf
Making Magento Magnificent for Marketing - Brighton SEO Spring 2023.pdf
 
300 best boolean strings - table of contents
300 best boolean strings - table of contents300 best boolean strings - table of contents
300 best boolean strings - table of contents
 
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
MongoDB .local Toronto 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pi...
 
Become a Ninja Recruiter: Advanced Boolean Search | Talent Connect London 2014
Become a Ninja Recruiter: Advanced Boolean Search | Talent Connect London 2014Become a Ninja Recruiter: Advanced Boolean Search | Talent Connect London 2014
Become a Ninja Recruiter: Advanced Boolean Search | Talent Connect London 2014
 
MongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective IndexingMongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
MongoDB .local Toronto 2019: Tips and Tricks for Effective Indexing
 
How to Make eCommerce Product Pages Content Unique
How to Make eCommerce Product Pages Content  UniqueHow to Make eCommerce Product Pages Content  Unique
How to Make eCommerce Product Pages Content Unique
 
Intent-Based International Keyword Research - International Search Summit, Ba...
Intent-Based International Keyword Research - International Search Summit, Ba...Intent-Based International Keyword Research - International Search Summit, Ba...
Intent-Based International Keyword Research - International Search Summit, Ba...
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
XPath for web scraping
XPath for web scrapingXPath for web scraping
XPath for web scraping
 
Entrepreneurial Operating System - A keynote
Entrepreneurial Operating System - A keynoteEntrepreneurial Operating System - A keynote
Entrepreneurial Operating System - A keynote
 
Undrop for InnoDB
Undrop for InnoDBUndrop for InnoDB
Undrop for InnoDB
 
SERVERLESS MIDDLEWARE IN AZURE FUNCTIONS
SERVERLESS MIDDLEWARE IN AZURE FUNCTIONSSERVERLESS MIDDLEWARE IN AZURE FUNCTIONS
SERVERLESS MIDDLEWARE IN AZURE FUNCTIONS
 
How to Get People to Respond to Your Recruiting Emails & Messages
How to Get People to Respond to Your Recruiting Emails & MessagesHow to Get People to Respond to Your Recruiting Emails & Messages
How to Get People to Respond to Your Recruiting Emails & Messages
 
Jquery Giriş
Jquery GirişJquery Giriş
Jquery Giriş
 
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
Revisão AP1 Construção de Páginas Web - CEDERJ
Revisão AP1 Construção de Páginas Web - CEDERJRevisão AP1 Construção de Páginas Web - CEDERJ
Revisão AP1 Construção de Páginas Web - CEDERJ
 
APEX Interactive Grid API Essentials: The Stuff You Will Really Use
APEX Interactive Grid API Essentials:  The Stuff You Will Really UseAPEX Interactive Grid API Essentials:  The Stuff You Will Really Use
APEX Interactive Grid API Essentials: The Stuff You Will Really Use
 
HELP! I've Been Hit By An Algorithm Update - Jess Maloney - BrightonSEO Apri...
HELP! I've Been Hit By An Algorithm Update - Jess Maloney - BrightonSEO  Apri...HELP! I've Been Hit By An Algorithm Update - Jess Maloney - BrightonSEO  Apri...
HELP! I've Been Hit By An Algorithm Update - Jess Maloney - BrightonSEO Apri...
 
TCS: MORE Freakishly Effective Marketing Hacks From Traffic & Conversion Summit
TCS: MORE Freakishly Effective Marketing Hacks From Traffic & Conversion SummitTCS: MORE Freakishly Effective Marketing Hacks From Traffic & Conversion Summit
TCS: MORE Freakishly Effective Marketing Hacks From Traffic & Conversion Summit
 
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
 

Similar to 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 Algorithm & Coding Interview
Cracking the Algorithm & Coding InterviewCracking the Algorithm & Coding Interview
Cracking the Algorithm & Coding InterviewGayle 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
 
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
 

Similar to Cracking the Facebook Coding Interview (6)

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 Algorithm & Coding Interview
Cracking the Algorithm & Coding InterviewCracking the Algorithm & Coding Interview
Cracking the Algorithm & Coding Interview
 
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
 
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
 

More from Gayle McDowell

Cracking the PM Interview
Cracking the PM InterviewCracking the PM Interview
Cracking the PM InterviewGayle 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
 
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
 
Creating the (Im)perfect Developer Interview
Creating the (Im)perfect Developer InterviewCreating the (Im)perfect Developer Interview
Creating the (Im)perfect Developer InterviewGayle 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
 

More from Gayle McDowell (11)

Cracking the PM Interview
Cracking the PM InterviewCracking the PM Interview
Cracking the PM Interview
 
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
 
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
 
Creating the (Im)perfect Developer Interview
Creating the (Im)perfect Developer InterviewCreating the (Im)perfect Developer Interview
Creating the (Im)perfect Developer Interview
 
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)
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

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