Slide 1

Slide 1 text

Surviving & Thriving in Technical Interviews By Jeremy Lindblom

Slide 2

Slide 2 text

Surviving & Thriving in Technical Interviews Making your brain do hard things while under pressure Why is it so hard?!

Slide 3

Slide 3 text

This Presentation – Who is it for? Junior and intermediate developers seeking job titles like: §  Software Engineer §  Software Developer §  Web Developer §  Computer Programmer

Slide 4

Slide 4 text

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.)

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

What Are Interviewers Looking For? ü  Ability to solve problems ü  Technical skills ü  Soft Skills ü  Team Fit

Slide 7

Slide 7 text

§  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

Slide 8

Slide 8 text

Good technical interview questions are designed to help employers understand, not what you know, but how you think. Ability to Solve Problems

Slide 9

Slide 9 text

§  Domain-specific Knowledge §  Data Structures §  Algorithms §  Design Patterns §  Recursion §  Big Data Technical Skills

Slide 10

Slide 10 text

Do You Need a CS Degree? ?  

Slide 11

Slide 11 text

Do You Need a CS Degree? NO  

Slide 12

Slide 12 text

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:

Slide 13

Slide 13 text

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.

Slide 14

Slide 14 text

§  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

Slide 15

Slide 15 text

§  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

Slide 16

Slide 16 text

§  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

Slide 17

Slide 17 text

§  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()  

Slide 18

Slide 18 text

§  Array §  Hash §  Linked List §  Stack §  Queue §  Tree §  Heap §  Graph §  Traversal §  Balancing §  Shortest Path §  Cycle Detection §  etc. Data Structures & Algorithms

Slide 19

Slide 19 text

§  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!)  

Slide 20

Slide 20 text

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!)  

Slide 21

Slide 21 text

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!)  

Slide 22

Slide 22 text

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!)  

Slide 23

Slide 23 text

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!)  

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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)  

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

§  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

Slide 30

Slide 30 text

§  Table Tennis? Soft Skills

Slide 31

Slide 31 text

§  Communication §  Teamwork §  Leadership §  Confidence §  Responsibility See Amazon Leadership Principles - http://amzn.to/Qb6JB6 Soft Skills

Slide 32

Slide 32 text

Technical Interview Question Examples

Slide 33

Slide 33 text

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 “ ”

Slide 34

Slide 34 text

Example #1 – The Raffle §  Tickets are numbered from 1 to 1,000,000 §  Select 700,000 random winners §  No duplicates

Slide 35

Slide 35 text

The Raffle – Solution #1 $winners  =  array_rand(    array_fill_keys(range(1,  1000000),  true),    700000   );  

Slide 36

Slide 36 text

The Raffle – Solution #1 PROS §  ???   $winners  =  array_rand(array_fill_keys(range(1,  1000000),  true),  700000);  

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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);  

Slide 39

Slide 39 text

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);  

Slide 40

Slide 40 text

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);    

Slide 41

Slide 41 text

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 §  ???

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

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 §  ???

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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)

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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 §  ???

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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  

Slide 52

Slide 52 text

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"

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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.

Slide 55

Slide 55 text

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.

Slide 56

Slide 56 text

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.

Slide 57

Slide 57 text

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  …  

Slide 58

Slide 58 text

Odd Duck – Exercise

Slide 59

Slide 59 text

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)

Slide 60

Slide 60 text

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.

Slide 61

Slide 61 text

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)

Slide 62

Slide 62 text

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.

Slide 63

Slide 63 text

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…)

Slide 64

Slide 64 text

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

Slide 65

Slide 65 text

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)

Slide 66

Slide 66 text

Preparation and Tips

Slide 67

Slide 67 text

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

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

Interview Tips Don't Panic

Slide 71

Slide 71 text

Interview Tips §  Don't panic §  Ask questions §  Be honest and direct §  Stay on topic §  Show your skills §  Be positive §  Learn something

Slide 72

Slide 72 text

Any Questions? Presentation by Jeremy Lindblom @jeremeamia Thanks! Rate: https://joind.in/10820