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.

Jeremy Lindblom

April 20, 2013
Tweet

More Decks by Jeremy Lindblom

Other Decks in Programming

Transcript

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

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

    developers seeking job titles like: §  Software Engineer §  Software Developer §  Web Developer §  Computer Programmer
  3. 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.)
  4. 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
  5. What Are Interviewers Looking For? ü  Ability to solve problems

    ü  Technical skills ü  Soft Skills ü  Team Fit
  6. §  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
  7. Good technical interview questions are designed to help employers understand,

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

    Patterns §  Recursion §  Big Data Technical Skills
  9. 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:
  10. 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.
  11. §  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
  12. §  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
  13. §  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
  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 sort()   array_search()  
  15. §  Array §  Hash §  Linked List §  Stack § 

    Queue §  Tree §  Heap §  Graph §  Traversal §  Balancing §  Shortest Path §  Cycle Detection §  etc. Data Structures & Algorithms
  16. §  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!)  
  17. 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!)  
  18. 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!)  
  19. 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!)  
  20. 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!)  
  21. Big-O Notation & Time Complexity Example #1     $index

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

     =  array_search(13,  $nums);   //  similar  to...   foreach  ($nums  as  $index  =>  $num)  {          if  ($num  ==  13)  break;     }  
  23. 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)  
  24. Big-O Notation & Time Complexity Example #2     foreach

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

     ($users  as  $user)  {      foreach  ($user-­‐>friends  as  $friend)  {          echo  $friend-­‐>name  .  "\n";      }   }     Quadratic – O(n2)  
  26. §  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
  27. §  Communication §  Teamwork §  Leadership §  Confidence §  Responsibility

    See Amazon Leadership Principles - http://amzn.to/Qb6JB6 Soft Skills
  28. 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 “ ”
  29. Example #1 – The Raffle §  Tickets are numbered from

    1 to 1,000,000 §  Select 700,000 random winners §  No duplicates
  30. The Raffle – Solution #1 PROS §  ???   $winners

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

    native functions §  Pretty fast §  O(n)   $winners  =  array_rand(array_fill_keys(range(1,  1000000),  true),  700000);  
  32. 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);  
  33. 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);  
  34. 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);    
  35. 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 §  ???
  36. 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
  37. 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 §  ???
  38. 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
  39. 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)
  40. The Raffle – Solution #3 $winners  =  range(1,  1000000);  

    shuffle($winners);   $winners  =  array_slice($winners,  0,  700000);     PROS §  ???
  41. 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
  42. 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 §  ???
  43. 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
  44. 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  
  45. 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"
  46. Odd Duck – Before You Start §  It's OK to

    ask clarifying questions §  What kind of questions would you ask?
  47. 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.
  48. 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.
  49. 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.
  50. 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  …  
  51. 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)
  52. 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.
  53. 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)
  54. 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.
  55. 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…)
  56. 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
  57. 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)
  58. 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
  59. 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
  60. 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
  61. Interview Tips §  Don't panic §  Ask questions §  Be

    honest and direct §  Stay on topic §  Show your skills §  Be positive §  Learn something