Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Surviving and Thriving in Technical Interviews

Surviving and Thriving in Technical Interviews

Technical interviews can a difficult and stressful part of finding employment. Regardless of whether or not you receive the job offer, you can make the technical interview process a good experience every time. In this session, you will learn some tips for your next technical interview, and also analyze some example interview and coding questions to learn how to think about and answer questions in a way that shows off your abilities.

Ca57a7cfac69ba3abf517470f3770aae?s=128

Jeremy Lindblom

April 20, 2013
Tweet

Transcript

  1. Surviving & Thriving in Technical Interviews By Jeremy Lindblom

  2. Surviving & Thriving in Technical Interviews Making your brain do

    hard things while under pressure Why is it so hard?!
  3. This Presentation – Who is it for? Junior and intermediate

    developers seeking job titles like: §  Software Engineer §  Software Developer §  Web Developer §  Computer Programmer
  4. This Presentation – Keep in Mind… §  Every employer and

    job is different. §  If you don’t recognize a technical term, be sure to read about it later. §  I’m not an expert; I’m just like you. (However, I’ve been interviewed and given interviews many times.)
  5. PHP Software Engineer at Co-author of the AWS SDK for

    PHP Co-organizer of the Seattle PHP User Group Zend Education Advisory Board for 5.5 exam Hello! I'm @jeremeamia
  6. What Are Interviewers Looking For? ü  Ability to solve problems

    ü  Technical skills ü  Soft Skills ü  Team Fit
  7. §  Understand the problem §  Deal with ambiguity §  Think

    logically §  Explain Yourself §  Propose a solution §  Analyze solution §  Make improvements §  Handle changes or constraints Ability to Solve Problems
  8. Good technical interview questions are designed to help employers understand,

    not what you know, but how you think. Ability to Solve Problems
  9. §  Domain-specific Knowledge §  Data Structures §  Algorithms §  Design

    Patterns §  Recursion §  Big Data Technical Skills
  10. Do You Need a CS Degree? ?  

  11. Do You Need a CS Degree? NO  

  12. Do You Need a CS Degree? Didn’t  Study  CS  

    BS  in  CS   Doesn’t  Know   CS  Topics   Clueless   Slacker   Knows   CS  Topics   ✓   ✓   What employers think about you:
  13. Do You Need a CS Degree? Bachelor’s Degree in Computer

    Science or related field — OR — 4+ years of job-related experience. “ ” Neither of these are hard requirements.
  14. §  Array §  Hash §  Linked List §  Stack § 

    Queue §  Tree §  Heap §  Graph §  Searching §  Linear Search §  Binary Search §  Sorting §  Selection Sort §  Insertion Sort §  Merge Sort §  Quicksort §  Bucket Sort Data Structures & Algorithms
  15. §  Array §  Hash §  Linked List §  Stack § 

    Queue §  Tree §  Heap §  Graph §  Searching §  Linear Search §  Binary Search §  Sorting §  Selection Sort §  Insertion Sort §  Merge Sort §  Quicksort §  Bucket Sort Data Structures & Algorithms
  16. §  Array §  Hash §  Linked List §  Stack § 

    Queue §  Tree §  Heap §  Graph §  Searching §  Linear Search §  Binary Search §  Sorting §  Selection Sort §  Insertion Sort §  Merge Sort §  Quicksort §  Bucket Sort Data Structures & Algorithms
  17. §  Array §  Hash §  Linked List §  Stack § 

    Queue §  Tree §  Heap §  Graph §  Searching §  Linear Search §  Binary Search §  Sorting §  Selection Sort §  Insertion Sort §  Merge Sort §  Quicksort §  Bucket Sort Data Structures & Algorithms sort()   array_search()  
  18. §  Array §  Hash §  Linked List §  Stack § 

    Queue §  Tree §  Heap §  Graph §  Traversal §  Balancing §  Shortest Path §  Cycle Detection §  etc. Data Structures & Algorithms
  19. §  Classifies algorithms by time complexity (how processing time is

    affected by input size) §  Consider best, average, and worst case §  Basic Classifications: Big-O Notation & Time Complexity §  Constant – O(1) or O(c)   §  Logarithmic – O(log  n)   §  Linear – O(n)   §  Linearithmic – O(n  log  n)   §  Quadratic – O(n2)   §  Polynomial – O(nc)   §  Exponential – O(cn)   §  Factorial – O(n!)  
  20. BEST Big-O Notation & Time Complexity §  Constant – O(1)

    or O(c)   §  Logarithmic – O(log  n)   §  Linear – O(n)   §  Linearithmic – O(n  log  n)   §  Quadratic – O(n2)   §  Polynomial – O(nc)   §  Exponential – O(cn)   §  Factorial – O(n!)  
  21. SEARCHING: Big-O Notation & Time Complexity §  Constant – O(1)

    or O(c)   §  Logarithmic – O(log  n)   §  Linear – O(n)   §  Linearithmic – O(n  log  n)   §  Quadratic – O(n2)   §  Polynomial – O(nc)   §  Exponential – O(cn)   §  Factorial – O(n!)  
  22. SORTING: Big-O Notation & Time Complexity §  Constant – O(1)

    or O(c)   §  Logarithmic – O(log  n)   §  Linear – O(n)   §  Linearithmic – O(n  log  n)   §  Quadratic – O(n2)   §  Polynomial – O(nc)   §  Exponential – O(cn)   §  Factorial – O(n!)  
  23. DANGER: Big-O Notation & Time Complexity §  Constant – O(1)

    or O(c)   §  Logarithmic – O(log  n)   §  Linear – O(n)   §  Linearithmic – O(n  log  n)   §  Quadratic – O(n2)   §  Polynomial – O(nc)   §  Exponential – O(cn)   §  Factorial – O(n!)  
  24. Big-O Notation & Time Complexity Example #1     $index

     =  array_search(13,  $nums);  
  25. Big-O Notation & Time Complexity Example #1     $index

     =  array_search(13,  $nums);   //  similar  to...   foreach  ($nums  as  $index  =>  $num)  {          if  ($num  ==  13)  break;     }  
  26. Big-O Notation & Time Complexity Example #1     $index

     =  array_search(13,  $nums);   //  similar  to...   foreach  ($nums  as  $index  =>  $num)  {          if  ($num  ==  13)  break;     }     Linear – O(n)  
  27. Big-O Notation & Time Complexity Example #2     foreach

     ($users  as  $user)  {      foreach  ($user-­‐>friends  as  $friend)  {          echo  $friend-­‐>name  .  "\n";      }   }  
  28. Big-O Notation & Time Complexity Example #2     foreach

     ($users  as  $user)  {      foreach  ($user-­‐>friends  as  $friend)  {          echo  $friend-­‐>name  .  "\n";      }   }     Quadratic – O(n2)  
  29. §  The amount of memory cells an algorithm needs. § 

    Often have to evaluate tradeoffs between space and time complexity. §  e.g., Doing things "in-place" or not Space Complexity
  30. §  Table Tennis? Soft Skills

  31. §  Communication §  Teamwork §  Leadership §  Confidence §  Responsibility

    See Amazon Leadership Principles - http://amzn.to/Qb6JB6 Soft Skills
  32. Technical Interview Question Examples

  33. I don't mind doing interviews. I don't mind answering thoughtful

    questions. But I'm not thrilled about answering questions like, 'If you were being mugged, and you had a light saber in one pocket and a whip in the other, which would you use?' – Harrison Ford “ ”
  34. Example #1 – The Raffle §  Tickets are numbered from

    1 to 1,000,000 §  Select 700,000 random winners §  No duplicates
  35. The Raffle – Solution #1 $winners  =  array_rand(    array_fill_keys(range(1,

     1000000),  true),    700000   );  
  36. The Raffle – Solution #1 PROS §  ???   $winners

     =  array_rand(array_fill_keys(range(1,  1000000),  true),  700000);  
  37. The Raffle – Solution #1 PROS §  Succinct §  Uses

    native functions §  Pretty fast §  O(n)   $winners  =  array_rand(array_fill_keys(range(1,  1000000),  true),  700000);  
  38. The Raffle – Solution #1 PROS §  Succinct §  Uses

    native functions §  Pretty fast §  O(n)   CONS §  ??? $winners  =  array_rand(array_fill_keys(range(1,  1000000),  true),  700000);  
  39. The Raffle – Solution #1 PROS §  Succinct §  Uses

    native functions §  Pretty fast §  O(n)   CONS §  Memory hog! §  Crashes on higher numbers §  Not very random due to array_rand() $winners  =  array_rand(array_fill_keys(range(1,  1000000),  true),  700000);  
  40. The Raffle – Solution #2 $winners  =  array();   for

     ($i  =  1;  $i  <=  700000;  $i++)  {        $n  =  mt_rand(1,  1000000);        if  (isset($winners[$n]))  {              $i-­‐-­‐;        }  else  {              $winners[$n]  =  true;        }   }   $winners  =  array_keys($winners);    
  41. The Raffle – Solution #2 $winners  =  array();   for

     ($i  =  1;  $i  <=  700000;  $i++)   {          $n  =  mt_rand(1,  1000000);          if  (isset($winners[$n]))  {                  $i-­‐-­‐;          }  else  {                  $winners[$n]  =  true;          }   }   $winners  =  array_keys($winners);   PROS §  ???
  42. The Raffle – Solution #2 $winners  =  array();   for

     ($i  =  1;  $i  <=  700000;  $i++)   {          $n  =  mt_rand(1,  1000000);          if  (isset($winners[$n]))  {                  $i-­‐-­‐;          }  else  {                  $winners[$n]  =  true;          }   }   $winners  =  array_keys($winners);   PROS §  Lower memory than #1 §  Decent randomness
  43. The Raffle – Solution #2 $winners  =  array();   for

     ($i  =  1;  $i  <=  700000;  $i++)   {          $n  =  mt_rand(1,  1000000);          if  (isset($winners[$n]))  {                  $i-­‐-­‐;          }  else  {                  $winners[$n]  =  true;          }   }   $winners  =  array_keys($winners);   PROS §  Lower memory than #1 §  Decent randomness CONS §  ???
  44. The Raffle – Solution #2 $winners  =  array();   for

     ($i  =  1;  $i  <=  700000;  $i++)   {          $n  =  mt_rand(1,  1000000);          if  (isset($winners[$n]))  {                  $i-­‐-­‐;          }  else  {                  $winners[$n]  =  true;          }   }   $winners  =  array_keys($winners);   PROS §  Lower memory than #1 §  Decent randomness CONS §  Not really O(n) §  ~10x slower than #1 §  Extra step to get results
  45. The Raffle – Solution #2 $winners  =  array();   for

     ($i  =  1;  $i  <=  700000;  $i++)   {          $n  =  mt_rand(1,  1000000);          if  (isset($winners[$n]))  {                  $i-­‐-­‐;          }  else  {                  $winners[$n]  =  $n;          }   }   $winners  =  array_keys($winners);   PROS §  Lower memory than #1 §  Decent randomness CONS §  Not really O(n) §  ~10x slower than #1 §  Extra step to get results (Thanks @auroraeosrose)
  46. The Raffle – Solution #3 $winners  =  range(1,  1000000);  

    shuffle($winners);   $winners  =  array_slice($winners,  0,  700000);     PROS §  ???
  47. The Raffle – Solution #3 $winners  =  range(1,  1000000);  

    shuffle($winners);   $winners  =  array_slice($winners,  0,  700000);     PROS §  Fast / O(n) §  Simple §  Lower memory than #1
  48. The Raffle – Solution #3 $winners  =  range(1,  1000000);  

    shuffle($winners);   $winners  =  array_slice($winners,  0,  700000);     PROS §  Fast / O(n) §  Simple §  Lower memory than #1 CONS §  ???
  49. The Raffle – Solution #3 $winners  =  range(1,  1000000);  

    shuffle($winners);   $winners  =  array_slice($winners,  0,  700000);     PROS §  Fast / O(n) §  Simple §  Lower memory than #1 CONS §  More random than #1, but not as random as #2
  50. The Raffle – Follow Up What if there were 1,000,000,000

    tickets?
  51. The Raffle – Follow Up What if there were 1,000,000,000

    tickets? php  >  $r  =  range(1,  1000000000);   PHP  Fatal  error:    Allowed  memory  size  of  536870912  bytes  exhausted  
  52. Example #2 – Odd Duck §  Input: an array of

    non-negative integers §  Integers in the array all exist an even number of times §  Except for one of them… Find the "odd duck"
  53. Odd Duck – Before You Start §  It's OK to

    ask clarifying questions §  What kind of questions would you ask?
  54. Odd Duck – Before You Start §  It's OK to

    ask clarifying questions §  What kind of questions would you ask? §  Is a single-element array valid? Yes.
  55. Odd Duck – Before You Start §  It's OK to

    ask clarifying questions §  What kind of questions would you ask? §  Is a single-element array valid? Yes. §  Is the array sorted? No.
  56. Odd Duck – Before You Start §  It's OK to

    ask clarifying questions §  What kind of questions would you ask? §  Is a single-element array valid? Yes. §  Is the array sorted? No. §  Can there be more than one instance of the "odd duck"? Yes.
  57. Odd Duck – Before You Start §  It's OK to

    ask clarifying questions §  What kind of questions would you ask? §  Is an empty array valid? No. §  Is a single-element array valid? Yes. §  Is the array sorted? No. §  Can there be more than one instance of the "odd duck"? Yes. …  8  5  42  8  8  9  1   42  1  1  8  9  5  …  
  58. Odd Duck – Exercise

  59. Odd Duck – Solutions 1.  For each number in the

    array, count the occurrences of that number and check if it's odd. Bad choice: O(n2)
  60. Odd Duck – Solutions 1.  For each number in the

    array, count the occurrences of that number and check if it's odd. Bad choice: O(n2)   2.  Use a 2nd array to count the occurrences of each number, then look in that 2nd array for the odd count.
  61. Odd Duck – Solutions 1.  For each number in the

    array, count the occurrences of that number and check if it's odd. Bad choice: O(n2)   2.  Use a 2nd array to count the occurrences of each number, then look in that 2nd array for the odd count. 3.  Sort the array, and then look for the first occurrence of a number that exists an odd number of times. (Bonus points: look in pairs)
  62. Odd Duck – Solutions 1.  For each number in the

    array, count the occurrences of that number and check if it's odd. Bad choice: O(n2)   2.  Use a 2nd array to count the occurrences of each number, then look in that 2nd array for the odd count. 3.  Sort the array, and then look for the first occurrence of a number that exists an odd number of times. (Bonus points: look in pairs) 4.  Use a 2nd array. When you encounter a number, add it to the 2nd array (as the key). When you encounter it again, remove/unset it.
  63. Odd Duck – Solutions 1.  For each number in the

    array, count the occurrences of that number and check if it's odd. Bad choice: O(n2)   2.  Use a 2nd array to count the occurrences of each number, then look in that 2nd array for the odd count. 3.  Sort the array, and then look for the first occurrence of a number that exists an odd number of times. (Bonus points: look in pairs) 4.  Use a 2nd array. When you encounter a number, add it to the 2nd array (as the key). When you encounter it again, remove/unset it. 5.  XOR all of the array elements together. (Oh…)
  64. Other Example Questions •  Find all of the anagrams of

    a word •  Find all valid words on a Boggle board •  Design an airline reservation system •  Reverse a string, array, or linked list •  Implement factorial w/ & w/out recursion •  Find all files containing phone numbers
  65. Interview Question Resources •  http://www.techinterview.org •  http://www.careercup.com •  http://programmerpuzzlers.com • 

    https://projecteuler.net/problems •  Lots of other non-free resources available •  (Let me know if you find some others)
  66. Preparation and Tips

  67. Preparing for the Questions §  Research your potential employer § 

    Review your own résumé §  Review the job description §  Practice technical interview questions §  Review data structures and algorithms §  Be prepared for behavioral questions
  68. Behavioral Questions §  Questions related to past experiences §  "Give

    me an example of a time when…" §  "Tell me about something you did that…" §  "How do you handle a situation where…" §  Plan some good experiences to share §  Talk about "I", not "we", but be honest §  Be prepared to provide details
  69. Physical Preparations §  Be well-rested §  Arrive a little early

    §  Use the restroom before the interview §  Turn off your phone §  Assume business casual dress unless you are told otherwise
  70. Interview Tips Don't Panic

  71. Interview Tips §  Don't panic §  Ask questions §  Be

    honest and direct §  Stay on topic §  Show your skills §  Be positive §  Learn something
  72. Any Questions? Presentation by Jeremy Lindblom @jeremeamia Thanks! Rate: https://joind.in/10820