surviving and thriving in technical interviews

Post on 05-Dec-2014

342 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

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.

TRANSCRIPT

Surviving & Thriving in Technical Interviews

Making your brain do hard things while under pressure

Surviving & Thriving in Technical Interviews

Making your brain do hard things while under pressure

Why is it so hard?!

What Are Interviewers Looking For?

ü  Ability to solve problems

ü  Technical skills

ü  Soft Skills

ü  Team Fit

§  Understand the problem

§  Think logically

§  Explain Yourself

§  Propose a solution

§  Analyze solution

§  Make improvements

§  Handle changes or constraints

Ability to Solve Problems

§  Domain-specific Knowledge

§  Data Structures

§  Algorithms

§  Design Patterns

§  Dealing with Large Data Sets

Technical Skills

§  Array §  Hash Map §  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

§  Used to classify algorithms by their time complexity – how their processing time is affected by input size.

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

§  The amount of memory cells an algorithm needs.

§  Often have to evaluate tradeoffs between space and time complexity

§  Doing things "in-place" or not

Space Complexity

§  Communication

§  Teamwork

§  Leadership

§  Confidence

§  Responsibility

See Amazon Leadership Principles - http://amzn.to/Qb6JB6

Soft Skills

Technical Interview Question Examples

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

Example #1 – The Raffle

§  Tickets are numbered from 1 to 1,000,000

§  Select 700,000 random winners

§  No duplicates

The Raffle – Solution #1

$winners  =  array_rand(    array_fill_keys(range(1,  1000000),  true),    700000  

);  

The Raffle – Solution #1

PROS

§  Succinct

§  Uses native functions

§  Pretty fast

§  O(n)  

$winners  =  array_rand(array_fill_keys(range(1,  1000000),  true),  700000);  

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 how array_rand()

works

$winners  =  array_rand(array_fill_keys(range(1,  1000000),  true),  700000);  

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

Note: The "mt" in mt_rand()  stands for Mersenne Twister.

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

§  Very good randomness

CONS

§  Not really O(n)

§  ~10x slower than #1

§  Extra step to get results

The Raffle – Solution #3

$winners  =  range(1,  1000000);  shuffle($winners);  $winners  =  array_slice($winners,  0,  700000);    

PROS

§  Fast

§  O(n)

§  Lower memory than #1

CONS

§  More random than #1, but not as random as #2

CONS

§  More random than #1, but not as random as #2

PROS

§  Fast

§  O(n)

§  Low memory

The Raffle – Solution #3

$winners  =  range(1,  1000000);  shuffle($winners);  $winners  =  array_slice($winners,  0,  700000);    

How To Improve: Use a Fisher-Yates shuffle algorithm that is seeded with mt_rand(). This would increase the randomness without negatively affecting performance.

The Raffle – Follow Up

What if there were 1,000,000,000 tickets?

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  

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"

Odd Duck – Before You Start

§  It's OK to ask clarifying questions

§  What kind of questions would you ask?

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.

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  …  

Odd Duck – Exercise

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)

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

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

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)

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

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.

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

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

Preparation and Tips

Preparing for the Questions

§  Research your potential employer

§  Be familiar with your own résumé

§  Review the job description

§  Practice technical interview questions

§  Review data structures and algorithms

§  Be prepared for behavioral questions

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", and be honest

§  Be prepared to give details

Physical Preparations

§  Be well-rested

§  Arrive early

§  Use the restroom before the interview

§  Turn off your phone

§  Assume business casual dress unless you are told otherwise

Interview Tips

§  Don't Panic

§  Ask Questions

§  Don't Be Evasive

§  Show Your Skills

§  Be Positive

§  Learn Something

Any Questions?

Presentation by Jeremy Lindblom

@jeremeamia

Thanks!

top related