Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cracking the Coding interview (College)

3,937 views

Published on

Cracking the Coding interview (College Slides)

Published in: Career
  • How You Can Go From Dead Broke To Abundantly Wealthy By Using One Simple Mind Hack... ▲▲▲ https://tinyurl.com/y44vwbuh
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • GIVE HER A BIGGER PACKAGE THIS VALENTINE'S DAY ★★★ https://tinyurl.com/yy3nfggr
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Cracking the Coding interview (College)

  1. 1. GayleL. McDowell | Founder/ CEO gayle in/gaylemcdgayle Cracking the Coding Interview Harvard CareerCup.com
  2. 2. gayle in/gaylemcdgayleGayle Laakmann McDowell 2 Hi! I’m Gayle LaakmannMcDowell Author Interview Coach Interview Consulting <dev> </dev> (CS) (MBA)
  3. 3. Gayle Laakmann McDowell 3gayle in/gaylemcdgayle Yes! Slidesare online! Gayle.com  Click“Events”
  4. 4. Early Preparation Landing an interview 00
  5. 5. Gayle Laakmann McDowell 5gayle in/gaylemcdgayle How to Get an Interview Your Background  Education  Work Experience  Projects  Github/ OnlineProfile Make a great resume McDowell | CareerCup.com
  6. 6. Gayle Laakmann McDowell 6gayle in/gaylemcdgayle Did I mention… PROJECTS???
  7. 7. gayle in/gaylemcdgayle 7Gayle Laakmann McDowell How We Review Resumes 1. Pull resume out of giant stack 2. Spot-check: companies, projects, etc. 3. Skim bullets to see if you’ve written real code. 4. Go tonextresume & whine abouthowmany moreyouhaveleft. InterviewReject “Glancedat,”not read. 15seconds
  8. 8. How CS ResumeShouldLook Short (1 – 2 line bullets) 3 – 4 Projects Courses & independent Finished or unfinished List of Technical Skills Short! Cut the “fluff.” GPA if at least 3.0 max (in-major, overall) One Page Only! Unless > 10 years exp. A Real Resume Format with organized columns Focus on Accomplishments not responsibilities Observe: No Objective! Objectives / summaries are almost always useless.
  9. 9. gayle in/gaylemcdgayle 9Gayle Laakmann McDowell Talking to Recruiters Show:  What you’vedone(mobileapp?Show it!)  What you’reexcitedabout Have a “pitch” ready Weird is okay  (arrogantisnot) McDowell | CareerCup.com
  10. 10. Behavioral Questions The soft squishy stuff.
  11. 11. gayle in/gaylemcdgayleGayle Laakmann McDowell 11 The Pitch /Resume Walk-Through • Showsof success • Prompt the interviewer • Hobbies
  12. 12. Gayle Laakmann McDowell 12gayle in/gaylemcdgayle Your Past Work  1 – 2 Hard Projects  Hard/ cool  Youwerecentral  Technical depth  All Past Work  Challenges,architecture, tradeoffs,mistakes,successes, motivations  Whatdid YOU do?
  13. 13. Technical Questions Why why why why why why meeeee 02
  14. 14. gayle in/gaylemcdgayle 14Gayle Laakmann McDowell How You’re Judged How did you do RELATIVE to other candidates on the SAME question? … it’s about how quickly you solved it relative to other candidates. It’s not about how quickly you solved the problem…
  15. 15. gayle in/gaylemcdgayle 15 z Gayle Laakmann McDowell What Really Happens
  16. 16. gayle in/gaylemcdgayle 16 z Gayle Laakmann McDowell What Really Happens Knowledge Questions  +Coding Design/Scalability  +Coding Algorithms/Problem Solving  +Coding
  17. 17. Knowledge Questions How do indices work in SQL?
  18. 18. Gayle Laakmann McDowell 18gayle in/gaylemcdgayle Knowledge Questions If you list it, know it If you don’t know it, admit it  Deriveitifpossible.
  19. 19. Design How would you design TinyURL?
  20. 20. gayle in/gaylemcdgayle 20 z Gayle Laakmann McDowell How To Approach W W Y D A W hat ould ou o t ork
  21. 21. gayle in/gaylemcdgayle 21 z Gayle Laakmann McDowell How To Approach S K I R cope eycomponents dentify issues epair
  22. 22. gayle in/gaylemcdgayle 22 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 DiscussTop->Down
  23. 23. Gayle Laakmann McDowell 23gayle in/gaylemcdgayle How to Act DRIVE  Leadtheprocess  Be openaboutissues TEAMWORK  Beopentofeedback  Tweak asnecessary
  24. 24. gayle in/gaylemcdgayle 24 z Gayle Laakmann McDowell How To Prepare Read about design of major companies  Twitter,Facebook,Quora,Google,etc.  ThinkaboutWHY they’redesigned thatway Learn/review key concepts  Taskqueues,databases,sharding,etc. Practice questions
  25. 25. Algorithm Preparation Problem solving, not puzzles!
  26. 26. Gayle Laakmann McDowell 26gayle in/gaylemcdgayle Why? Strong CS fundamentals Analytical skills Make tradeoffs Push throughhard problems Communication How you think
  27. 27. gayle in/gaylemcdgayleGayle Laakmann McDowell 27 Essential Knowledge Data Structures Algorithms Concepts ArrayLists Merge Sort BigO Time Hash Tables QuickSort BigO Space Trees(+Tries) Breadth-FirstSearch Recursion Graphs Depth-FirstSearch Memoization/ Dynamic Programming Stacks/ Queues BinarySearch Heaps
  28. 28. gayle in/gaylemcdgayleGayle Laakmann McDowell 28 Preparation ImplementDS/Algorithms MASTER BigO Practice with interviewquestions Code on paper/whiteboard Mock interviews PUSHYOURSELF!
  29. 29. Solving Algorithms How to… attempt to solve a hard problem
  30. 30. gayle in/gaylemcdgayle 30 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.
  31. 31. gayle in/gaylemcdgayle 31 z Gayle Laakmann McDowell What IS expected Be excitedabout hard problems More thanjust “correct” Drive! Keeptrying when stuck Write real code Showmehowyouthink!
  32. 32. gayle in/gaylemcdgayle 32 z Gayle Laakmann McDowell How To Approach CrackingTheCodingInterview.com“Resources”
  33. 33. gayle in/gaylemcdgayle 33Gayle Laakmann McDowell step Listen (for clues)
  34. 34. Gayle Laakmann McDowell 34gayle in/gaylemcdgayle What’sthe clue? Anagram server  Ex: rates ->aster, stare, taser, tears Clue:why is it ona server?
  35. 35. gayle in/gaylemcdgayle 35Gayle Laakmann McDowell step Draw an Example Big Enough General Purpose +
  36. 36. gayle in/gaylemcdgayleGayle Laakmann McDowell 36 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 common element, sameindex
  37. 37. gayle in/gaylemcdgayleGayle Laakmann McDowell 37 Ex:Intersection ofTwo Sorted Arrays Better: [1, 12, 15, 19, 20, 21] [2, 15, 17, 19, 21, 25, 27]  Big  No specialcases
  38. 38. gayle in/gaylemcdgayle 38Gayle Laakmann McDowell step Brute Force / Naive Stupid&terribleisokay!
  39. 39. gayle in/gaylemcdgayle 39Gayle Laakmann McDowell step Optimize Walk through brute force Look for optimizations
  40. 40. Gayle Laakmann McDowell 40gayle in/gaylemcdgayle Techniques to Develop Algorithms Optimize A. BUD B. Space/time C. Doityourself Solve D. Recursion E. Solve “incorrectly” F. Other data structures Pushyourself!
  41. 41. Gayle Laakmann McDowell 41gayle in/gaylemcdgayle (A) Look for BUD Bottlenecks Unnecessary work Duplicated work
  42. 42. Gayle Laakmann McDowell 42gayle 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
  43. 43. Gayle Laakmann McDowell 43gayle in/gaylemcdgayle What’s unnecessary?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000  Unnecessary: looking for d U
  44. 44. Gayle Laakmann McDowell 44gayle in/gaylemcdgayle What’s unnecessary?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000  Unnecessary: looking for d U
  45. 45. Gayle Laakmann McDowell 45gayle in/gaylemcdgayle What’s duplicated?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000  Duplicated: c, d pairs D
  46. 46. Gayle Laakmann McDowell 46gayle 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 … … …
  47. 47. Gayle Laakmann McDowell 47gayle 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) … …
  48. 48. Gayle Laakmann McDowell 48gayle in/gaylemcdgayle What’s duplicated?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000 D
  49. 49. Gayle Laakmann McDowell 49gayle in/gaylemcdgayle What’s duplicated?  Ex: a3 + b3 = c3 + d3 (1 <=a,b, c, d<= 1000 D
  50. 50. Gayle Laakmann McDowell 50gayle in/gaylemcdgayle (B)Space/TimeTradeoffs Hashtables & other datastructures Precomputing
  51. 51. Gayle Laakmann McDowell 51gayle in/gaylemcdgayle Space/Time Tradeoffs  Precomputing  Find rectangle at origin w biggest sum 6 5 -9 2 -2 -5 -2 7 3 -2 10 13 -8 -3 1 -2  Brute force: compute all rectanglesand sums
  52. 52. Gayle Laakmann McDowell 52gayle in/gaylemcdgayle Space/Time Tradeoffs  Precomputing  Find rectangle with biggest sum 6 5 -9 2 -2 -5 -2 7 3 -2 10 13 -8 -3 1 -2 -+ + 10=
  53. 53. Gayle Laakmann McDowell 53gayle in/gaylemcdgayle Space/Time Tradeoffs  Precomputing  Find rectangle with biggest sum 6 5 -9 2 -2 -5 -2 7 3 -2 10 13 -8 -3 1 -2 -+ + 13=
  54. 54. Gayle Laakmann McDowell 54gayle in/gaylemcdgayle (C)Do it yourself Findpermutationsof swithinb  s = abbc  b = babcabbacaabcbabcacbb Findthem!  … now how didyou actuallydoit?
  55. 55. Gayle Laakmann McDowell 55gayle in/gaylemcdgayle Techniques to Develop Algorithms Optimize A. BUD B. Space/time C. Doityourself Solve D. Recursion E. Solve “incorrectly” F. Other data structures Pushyourself!
  56. 56. Gayle Laakmann McDowell 56gayle in/gaylemcdgayle (D) Recursion/ Base Case & Build Subsets of a set  {}  {}  {a}  {}, {a}  {a, b}  {}, {a}, {b}, {a, b}  {a, b, c}  … Subsets of {S1…Sn-1} + Sn to each • Careful!“This sounds recursive” is 50% accurate • Bottom-up approach, top-down implementation
  57. 57. Gayle Laakmann McDowell 57gayle in/gaylemcdgayle (E) Solve “incorrectly” ① Develop incorrectsolution ② Identifywhy preciselyit’s incorrect ③ Repair ④ (& Repeat)
  58. 58. Gayle Laakmann McDowell 58gayle in/gaylemcdgayle (E)Solve “incorrectly” Random node in BST Try: flipcoin Coin=Heads  Branch Left Coin=Tails  Branch Right
  59. 59. Gayle Laakmann McDowell 59gayle in/gaylemcdgayle (E)Solve “incorrectly” Random node in BST Try: random number in {0, 1, 2} R=0  Branch Left R=2  Branch Right R=1  Return root
  60. 60. Gayle Laakmann McDowell 60gayle in/gaylemcdgayle (E)Solve “incorrectly” Random node in BST Try:  Return rootwith1/n probability  Then flipcoin(heads left,tails->right)
  61. 61. Gayle Laakmann McDowell 61gayle in/gaylemcdgayle (E)Solve “incorrectly” Random node in BST Try: pick random # 0 throughn-1 R=0  Return root R>left.size  Branch right 1<=R<=left.size  Branch left
  62. 62. Gayle Laakmann McDowell 62gayle in/gaylemcdgayle (F) Other Data Structures Giving outphone numbers  “I wantany availablenumber”  “I wantthisnumber” Try: sorted array?Sorted linkedlist?Hashtable? BST?
  63. 63. gayle in/gaylemcdgayle 63Gayle Laakmann McDowell step Walk Through Know the variables andwhen they change
  64. 64. gayle in/gaylemcdgayle 64Gayle Laakmann McDowell step Write Beautiful Code
  65. 65. Gayle Laakmann McDowell 65gayle in/gaylemcdgayle How to Write WhiteboardCode Write straight Top-leftcorner Use arrows if needed Error cases / TODOs Good variables Modularized Languagechoiceisuptoyou!
  66. 66. gayle in/gaylemcdgayleGayle Laakmann McDowell 66 Modularization
  67. 67. gayle in/gaylemcdgayle 67Gayle Laakmann McDowell step Testing FIRST Analyze  What’sitdoing?Why?  Anythingthatlooksweird?  Errorhotspots THEN use test cases  Smalltestcases  Edgecases  Bigger testcases
  68. 68. Final Thoughts And questions 03
  69. 69. Gayle Laakmann McDowell 69gayle in/gaylemcdgayle ClosingAdvice Do projects Study for your interviews Chaseinterviews … but don’t chase money Check-inon your career.  Isthiswhatyouwanttodowithyourlife? McDowell | CareerCup.com
  70. 70. gayle in/gaylemcdgayle 70 z Gayle Laakmann McDowell It’s done for a reason! Be a great teammate. Be a great engineer.
  71. 71. gayle in/gaylemcdgayleGayle Laakmann McDowell 71 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

×