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

Longhorn PHP 2021 - Passing the Technical Interview Workshop

Ben Edmunds
October 14, 2021
55

Longhorn PHP 2021 - Passing the Technical Interview Workshop

Ben Edmunds

October 14, 2021
Tweet

Transcript

  1. passing the
    Technical
    Interview
    🛠 workshop

    View Slide

  2. Who is this guy?
    Ben Edmunds
    Open Source
    Author
    PHP Town Hall Podcast
    More Than Code Podcast
    Sr Staff Eng @ Wayfair

    View Slide

  3. Will Cover
    Technical interview process
    from Phone Screen to Offer

    View Slide

  4. Won’t Cover
    Everything before the

    Phone Screen

    View Slide

  5. View Slide

  6. My Last
    Job Search

    View Slide

  7. Your Next
    Job Search

    View Slide

  8. Prep

    View Slide

  9. View Slide

  10. 1

    Phone 

    Screen
    2

    Manager 

    Screen
    3

    Coding
    Test
    4
    Onsite
    Evals

    View Slide

  11. Stages
    0. Reach Out
    • Accepted application

    • Communication from
    Recruiter

    View Slide

  12. 1

    Phone 

    Screen
    2

    Manager 

    Screen
    3

    Coding
    Test
    4
    Onsite
    Evals

    View Slide

  13. Stages
    1. Phone Screen
    • High level

    • Why are you looking

    • What are you looking for

    • Pitch on company/role

    View Slide

  14. View Slide

  15. Stages
    1. Phone Screen
    • Why

    • What
    PREP

    View Slide

  16. Stages
    1. Phone Screen
    • Structure of teams

    • Favorite projects

    PREP

    View Slide

  17. Stages
    1. Phone Screen
    • $
    PREP

    View Slide

  18. View Slide

  19. 1

    Phone 

    Screen
    2

    Manager 

    Screen
    3

    Coding
    Test
    4
    Onsite
    Evals

    View Slide

  20. Stages
    • High level but deeper tech

    • Experience with specific
    technologies

    • Pitch on Company/Role
    2. Manager Screen

    View Slide

  21. View Slide

  22. Stages
    • Hard Problems

    • Best Projects

    • Failures

    • Technologies
    2. Manager Screen
    PREP

    View Slide

  23. View Slide

  24. 1

    Phone 

    Screen
    2

    Manager 

    Screen
    3

    Coding
    Test
    4
    Onsite
    Evals

    View Slide

  25. Stages
    3. Coding Test
    • Take Home

    • or

    • Online Platform

    View Slide

  26. Stages
    3. Coding Test - Take Home
    • Small project

    • Designing architecture

    • Designing APIs

    • Solving algorithms

    View Slide

  27. Stages
    3. Coding Test - Online
    • Small problem(s)

    • Algorithmic problem

    • Time complexity

    • Space complexity

    View Slide

  28. View Slide

  29. Stages
    3. Coding Test
    • Lite version of Coding and
    Sys Design on-site evals

    • Real world experience
    PREP

    View Slide

  30. Stages
    3. Coding Test
    • Sys Design & Architecture

    • Based on role 

    interviewing for
    PREP

    View Slide

  31. Stages
    3. Coding Test
    • APIs

    • REST

    • GraphQL

    • RPC
    PREP

    View Slide

  32. Stages
    3. Coding Test
    • Data Structures

    • Array, Stack, Queue, 

    BT, BST, Hash Table
    PREP

    View Slide

  33. Stages
    3. Coding Test
    • Algos

    • Common Techniques
    PREP

    View Slide

  34. Stages
    3. Coding Test
    • Algos

    • Pattern Matching
    PREP

    View Slide

  35. Stages
    3. Coding Test
    • Algos

    • Common Problems
    PREP
    + FizzBuzz, 8
    Queens, Boggle,
    Subset Sum, etc

    View Slide

  36. Stages
    3. Coding Test
    • Algos

    • Improvements
    PREP

    View Slide

  37. Stages
    3. Coding Test
    • Sorting

    • Bubble Sort

    • Quick Sort

    • Merge Sort
    PREP

    View Slide

  38. Stages
    3. Coding Test
    • Fill knowledge gaps
    PREP

    View Slide

  39. Stages
    3. Coding Test
    • PRACTICE
    PREP

    View Slide

  40. Time & Space
    Complexity

    View Slide

  41. Complexity
    Time Complexity

    Space Complexity

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  42. Complexity
    Big O notation

    images:https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/

    View Slide

  43. Complexity
    O(1)
    $input = [1,2,3,4,5];
    return $input[3];

    View Slide

  44. Complexity
    O(log N)
    for ($i=0; $i<=count($input); $i*=2) {}

    View Slide

  45. Complexity
    O(N)
    for ($i=0; $i<=count($input); $i++) {}

    View Slide

  46. Complexity
    O(N log N)
    for ($i=0; $i<=count($input); $i++) {
    for ($j=0; $j<=count($input); $j*=2) {}
    }

    View Slide

  47. Complexity
    O(N2)
    for ($i=0; $i<=count($input); $i++) {
    for ($j=0; $j<=count($input); $j++) {}
    }

    View Slide

  48. Complexity
    O(N!)
    function factorial($n) {
    $factorial = 1;
    for ($i = 1; $i <= $n; $i++){
    $factorial = $factorial * $i;
    }
    return $factorial;
    }
    for ($i = 0; $i <= factorial(8); $i++) { }

    View Slide

  49. Data
    Structures

    View Slide

  50. Data Structures
    Array

    Stack

    Queue

    Linked List

    Tree

    Graph

    Hash Table

    Linear Non-linear

    View Slide

  51. Data Structures
    Array

    Stack

    Queue

    Linked List

    Linear Non-linear
    Tree

    Graph

    Hash Table

    View Slide

  52. Data Structures
    array

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  53. Data Structures
    $array = ['Item1', 'Item2'];
    $array[0] => Item1

    View Slide

  54. Data Structures
    $array = [
    ['Item1-1', 'Item1-2'],
    ['Item2-1', 'Item2-2'],
    ];
    $array[0][1] => Item1-2

    View Slide

  55. Data Structures
    $array = [
    'namedIndex' => 'value'
    ];
    $array['namedIndex'] => value

    View Slide

  56. Data Structures
    stack

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  57. Data Structures
    $stack = [0, 1, 2];
    array_pop($stack) => 2
    var_dump($stack) => [0, 1]

    View Slide

  58. Data Structures
    public isEmpty() : bool
    public pop() : mixed
    public push(mixed $value) : void

    View Slide

  59. Data Structures
    $stack = new Stack([0, 1, 2]);
    $stack->pop() => 2
    var_dump($stack) => [0, 1]

    View Slide

  60. Data Structures
    $stack = new Stack([0, 1]);
    $stack->push() => 3
    var_dump($stack) => [3, 0, 1]

    View Slide

  61. Data Structures
    queue

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  62. Data Structures
    $queue = [0, 1, 2];
    array_pop_first($queue) => 0
    var_dump($queue) => [1, 2]

    View Slide

  63. Data Structures
    public isEmpty() : bool
    public pop() : mixed
    public push(mixed $value) : void

    View Slide

  64. Data Structures
    public isEmpty() : bool
    public dequeue() : mixed
    public enqueue(mixed $value) : void

    View Slide

  65. Data Structures
    $queue = new Queue([0, 1, 2]);
    $queue->pop() => 0
    var_dump($queue) => [1, 2]

    View Slide

  66. Data Structures
    $queue = new Queue([1, 2]);
    $queue->push() => 3
    var_dump($queue) => [1, 2, 3]

    View Slide

  67. Data Structures
    linked list

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  68. Data Structures
    doubly linked list

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  69. Data Structures
    $l = new SplDoublyLinkedList;
    $l->push('a');
    $l->push('b');
    $l->push('c');
    for ($l->rewind(); $l->valid(); $l->next()) {
    echo $l->current() . ', ';
    }
    => a, b, c

    View Slide

  70. Data Structures
    $l = new SplDoublyLinkedList;
    $l->push('a');
    $l->push('b');
    $l->push('c');
    $list->rewind();
    echo $list->current() . ', ';
    $list->next();
    echo $list->current() . ', ';
    $list->prev();
    echo $list->current();
    = > a, b, a

    View Slide

  71. Data Structures
    hash table

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  72. Data Structures
    $hashMap = [
    sha1('first') => 1,
    sha1('second') => 2
    ];
    $hashMap[sha1('first')] => 1

    View Slide

  73. Data Structures
    $hashMap = [];
    for ($i=1; $i<=10; $i++){
    $hash = $i % 3;
    $hashMap[$hash] =
    isset($hashMap[$hash]) ?
    $hashMap[$hash] + $i : $i;
    }
    $hashMap[0] => 18

    View Slide

  74. Data Structures
    graph

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  75. Data Structures
    graph

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  76. Data Structures
    graph

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures
    follow edges

    add to Queue

    process queue
    Breadth First
    Traversal

    View Slide

  77. Data Structures
    https://www.tutorialspoint.com/data_structures_algorithms/breadth_first_traversal.htm

    View Slide

  78. Data Structures
    graph

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures
    follow edges

    add to Stack

    process stack
    Depth First
    Traversal

    View Slide

  79. Data Structures
    https://www.tutorialspoint.com/data_structures_algorithms/breadth_first_traversal.htm

    View Slide

  80. Data Structures
    tree

    images: https://blog.devmountain.com/what-you-should-know-about-data-structures

    View Slide

  81. Data Structures
    binary search tree
    (BST)

    https://delboy1978uk.wordpress.com/2018/02/06/binary-search-trees-in-php/

    View Slide

  82. Data Structures
    binary search tree
    (BST)

    23?
    https://delboy1978uk.wordpress.com/2018/02/06/binary-search-trees-in-php/

    View Slide

  83. Data Structures
    binary search tree
    (BST)

    20?
    null
    https://delboy1978uk.wordpress.com/2018/02/06/binary-search-trees-in-php/

    View Slide

  84. Data Structures
    binary search tree
    (BST)

    Breadth First
    Traversal
    https://delboy1978uk.wordpress.com/2018/02/06/binary-search-trees-in-php/
    5,2,11,1,4,
    7,23,16,34

    View Slide

  85. Data Structures
    binary search tree
    (BST)

    Depth First
    Traversal
    https://delboy1978uk.wordpress.com/2018/02/06/binary-search-trees-in-php/
    5, 2, 1, 4,
    11, 7, 23,
    16, 34

    View Slide

  86. Data Structures
    class Node
    {
    public $left, $right, $data;
    function __construct($data) {
    $this->data = $data;
    }
    }

    View Slide

  87. Data Structures
    class BST
    {
    public $rootNode;
    public function __construct($data=null)
    {
    if ($data !== null) {
    $this->rootNode = new Node($data);
    }
    }

    View Slide

  88. Data Structures
    public function search($data)
    {
    $node = $this->rootNode;
    while($node) {
    if ($data < $node->data) {
    $node = $node->left;
    } else if ($data > $node->data) {
    $node = $node->right;
    } else {
    break;
    }
    }
    return $node;
    }

    View Slide

  89. Data Structures
    trees IRL

    https://en.wikipedia.org/wiki/Radix_tree

    View Slide

  90. Data Structures
    https://en.wikipedia.org/wiki/Radix_tree

    View Slide

  91. Algorithms

    View Slide

  92. Algorithms
    Techniques

    View Slide

  93. Algorithms
    techniques
    brute force

    View Slide

  94. Algorithms
    techniques
    divide and conquer

    View Slide

  95. Algorithms
    techniques
    dynamic

    View Slide

  96. Algorithms
    techniques
    greedy

    View Slide

  97. Algorithms
    techniques
    recursive

    View Slide

  98. Algorithms
    techniques
    backtracking

    View Slide

  99. Algorithms
    Sorting

    View Slide

  100. Algorithms
    quicksort
    https://en.wikipedia.org/wiki/Quicksort

    View Slide

  101. Algorithms
    quicksort
    https://en.wikipedia.org/wiki/Quicksort
    O(n log n)

    View Slide

  102. Algorithms
    merge sort
    https://en.wikipedia.org/wiki/Quicksort

    View Slide

  103. Algorithms
    merge sort
    https://en.wikipedia.org/wiki/Quicksort
    O(n log n)

    View Slide

  104. Algorithms
    Examples

    View Slide

  105. Algorithms
    fizz buzz
    Write a program that prints the numbers from 1 to 100
    and for multiples of ‘3’ print “Fizz” instead of the
    number and for the multiples of ‘5’ print “Buzz”.

    View Slide

  106. Algorithms
    for ($i=1; $i<=100; $i++) {
    if ($i%3 === 0) {
    echo 'Fizz';
    }
    else if ($i%5 === 0) {
    echo 'Buzz';
    }
    else {
    echo $i;
    }
    }

    View Slide

  107. Algorithms
    time complexity
    O(n)

    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  108. Algorithms
    single number
    Given a non-empty array of integers, every
    element appears twice except for one.

    Find that single one.

    View Slide

  109. Algorithms
    $input = [4, 1, 2, 1, 2];
    $noDups = [];
    foreach ($input as $value) {
    $k = array_search($value, $noDups);
    if ($k === false) {
    $noDups[] = $value;
    }
    else {
    unset($noDups[$k]);
    }
    }
    echo $noDups[0];

    View Slide

  110. Algorithms
    $input = [4, 1, 2, 1, 2];
    $noDups = [];
    foreach ($input as $value) {
    $k = array_search($value, $noDups);
    if ($k === false) {
    $noDups[] = $value;
    }
    else {
    unset($noDups[$k]);
    }
    }
    echo $noDups[0];

    View Slide

  111. Algorithms
    $input = [4, 1, 2, 1, 2];
    $noDups = [];
    foreach ($input as $value) {
    $k = array_search($value, $noDups);
    if ($k === false) {
    $noDups[] = $value;
    }
    else {
    unset($noDups[$k]);
    }
    }
    echo $noDups[0];

    View Slide

  112. Algorithms
    $input = [4, 1, 2, 1, 2];
    $noDups = [];
    foreach ($input as $value) {
    $k = array_search($value, $noDups);
    if ($k === false) {
    $noDups[] = $value;
    }
    else {
    unset($noDups[$k]);
    }
    }
    echo $noDups[0];

    View Slide

  113. Algorithms
    $input = [4, 1, 2, 1, 2];
    $noDups = [];
    foreach ($input as $value) {
    $k = array_search($value, $noDups);
    if ($k === false) {
    $noDups[] = $value;
    }
    else {
    unset($noDups[$k]);
    }
    }
    echo $noDups[0];

    View Slide

  114. Algorithms
    time complexity
    O(n2)

    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  115. Algorithms
    $input = [4, 1, 2, 1, 2];
    $hashmap = [];
    foreach ($input as $v) {
    $hashmap[$v] = isset($hashmap[$v]) ?
    $hashmap[$v]+1 : 1;
    }
    foreach ($hashmap as $k => $count) {
    if ($count === 1) {
    echo $k;
    break;
    }
    }

    View Slide

  116. Algorithms
    $input = [4, 1, 2, 1, 2];
    $hashmap = [];
    foreach ($input as $v) {
    $hashmap[$v] = isset($hashmap[$v]) ?
    $hashmap[$v]+1 : 1;
    }
    foreach ($hashmap as $k => $count) {
    if ($count === 1) {
    echo $k;
    break;
    }
    }

    View Slide

  117. Algorithms
    $input = [4, 1, 2, 1, 2];
    $hashmap = [];
    foreach ($input as $v) {
    $hashmap[$v] = isset($hashmap[$v]) ?
    $hashmap[$v]+1 : 1;
    }
    foreach ($hashmap as $k => $count) {
    if ($count === 1) {
    echo $k;
    break;
    }
    }

    View Slide

  118. Algorithms
    $hashmap = array(3) {
    [4]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(2)
    }

    View Slide

  119. Algorithms
    $input = [4, 1, 2, 1, 2];
    $hashmap = [];
    foreach ($input as $v) {
    $hashmap[$v] = isset($hashmap[$v]) ?
    $hashmap[$v]+1 : 1;
    }
    foreach ($hashmap as $k => $count) {
    if ($count === 1) {
    echo $k;
    break;
    }
    }

    View Slide

  120. Algorithms
    $input = [4, 1, 2, 1, 2];
    $hashmap = [];
    foreach ($input as $v) {
    $hashmap[$v] = isset($hashmap[$v]) ?
    $hashmap[$v]+1 : 1;
    }
    foreach ($hashmap as $k => $count) {
    if ($count === 1) {
    echo $k;
    break;
    }
    }

    View Slide

  121. Algorithms
    time complexity
    O(n)

    View Slide

  122. Algorithms
    8 queens
    Place eight queens on an 8×8 chessboard so that no
    two queens threaten each other; thus, a solution
    requires that no two queens share the same row,
    column, or diagonal.

    View Slide

  123. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  124. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  125. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  126. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  127. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  128. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  129. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  130. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  131. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  132. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  133. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  134. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  135. Algorithms
    public function run() : bool
    {
    // 8 to the power of 8 =
    // 16,777,216 possible board configurations
    $board = $this->generateBoard($hash);
    if (!$this->hasCollisions($board)) {
    return true;
    }
    $this->run($hash-1);
    }

    View Slide

  136. Algorithms
    time complexity
    Brute Force = O(nn)

    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  137. Algorithms
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  138. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  139. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  140. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  141. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  142. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  143. Algorithms
    8 queens
    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  144. Algorithms
    interface SolverInterface
    {
    public function getBoard() : array;
    public function format() : string;
    public function hasCollision(int $row, int $col) : bool;
    public function run(int $col) : bool;
    }
    class NQueensSolver implements SolverInterface {}

    View Slide

  145. Algorithms
    $solver = new NQueensSolver(8);
    $solver->run();
    $expectedBoard = [
    [1, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 1, 0],
    [0, 0, 0, 0, 1, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1],
    [0, 1, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 1, 0, 0],
    [0, 0, 1, 0, 0, 0, 0, 0]
    ];
    echo 'Tests ' .
    ($solver->getBoard() === $expectedBoard ?
    'passed 🎉' : 'failed 🚨');

    View Slide

  146. Algorithms
    public function __construct($n=8)
    {
    $this->n = $n;
    $this->board = array_fill(
    0, $n, array_fill(0, $n, 0)
    );
    }

    View Slide

  147. Algorithms
    $this->board = [
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0]
    ];

    View Slide

  148. Algorithms
    public function getBoard() : array
    {
    return $this->board;
    }

    View Slide

  149. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  150. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  151. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  152. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  153. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  154. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  155. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  156. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  157. Algorithms
    public function run($col=0) : bool
    {
    // return true if we've iterated over the whole board
    if ($col >= $this->n) {
    return true;
    }
    // iterate over the rows
    for ($row = 0; $row < $this->n; ++$row) {
    if (!$this->hasCollision($row, $col)) {
    // place a queen
    $this->board[$row][$col] = 1;
    // check the next column to see if this worked
    if ($this->run($col+1)) {
    return true;
    }
    // this didn't work so let's remove the queen, backtrack, and try the next row
    $this->board[$row][$col] = 0;
    }
    }
    return false;
    }

    View Slide

  158. Algorithms
    public function hasCollision(int $row, int $col) : bool
    {
    // check the current row
    for ($thisCol = 0; $thisCol < $col; ++$thisCol) {
    if ($this->board[$row][$thisCol]) {
    return true;
    }
    }
    // check diagonally to the top left
    // no need to check the top right since we're processing one column at a time
    for ($thisRow = $row, $thisCol = $col; $thisRow >= 0 && $thisCol >= 0; $thisRow--, $thisCol--) {
    if ($this->board[$thisRow][$thisCol]) {
    return true;
    }
    }
    // check diagonally to the bottom left
    // no need to check the bottom right since we're processing one column at a time
    for ($thisRow = $row, $thisCol = $col; $thisCol >= 0 && $thisRow < $this->n; $thisRow++, $thisCol--) {
    if ($this->board[$thisRow][$thisCol]) {
    return true;
    }
    }
    return false;
    }

    View Slide

  159. Algorithms
    public function hasCollision(int $row, int $col) : bool
    {
    // check the current row
    for ($thisCol = 0; $thisCol < $col; ++$thisCol) {
    if ($this->board[$row][$thisCol]) {
    return true;
    }
    }
    // check diagonally to the top left
    // no need to check the top right since we're processing one column at a time
    for ($thisRow = $row, $thisCol = $col; $thisRow >= 0 && $thisCol >= 0; $thisRow--, $thisCol--) {
    if ($this->board[$thisRow][$thisCol]) {
    return true;
    }
    }
    // check diagonally to the bottom left
    // no need to check the bottom right since we're processing one column at a time
    for ($thisRow = $row, $thisCol = $col; $thisCol >= 0 && $thisRow < $this->n; $thisRow++, $thisCol--) {
    if ($this->board[$thisRow][$thisCol]) {
    return true;
    }
    }
    return false;
    }

    View Slide

  160. Algorithms
    public function hasCollision(int $row, int $col) : bool
    {
    // check the current row
    for ($thisCol = 0; $thisCol < $col; ++$thisCol) {
    if ($this->board[$row][$thisCol]) {
    return true;
    }
    }
    // check diagonally to the top left
    // no need to check the top right since we're processing one column at a time
    for ($thisRow = $row, $thisCol = $col; $thisRow >= 0 && $thisCol >= 0; $thisRow--, $thisCol--) {
    if ($this->board[$thisRow][$thisCol]) {
    return true;
    }
    }
    // check diagonally to the bottom left
    // no need to check the bottom right since we're processing one column at a time
    for ($thisRow = $row, $thisCol = $col; $thisCol >= 0 && $thisRow < $this->n; $thisRow++, $thisCol--) {
    if ($this->board[$thisRow][$thisCol]) {
    return true;
    }
    }
    return false;
    }

    View Slide

  161. Algorithms
    time complexity
    Brute Force = O(nn)

    Backtracking = O(n!)

    https://en.wikipedia.org/wiki/Eight_queens_puzzle

    View Slide

  162. Data Structures
    algorithms IRL

    https://en.wikipedia.org/wiki/Radix_tree

    View Slide

  163. View Slide

  164. 🛠 WORKSHOP
    https://bit.ly/passTechInterview

    Initial Phone Coding Test

    View Slide

  165. View Slide

  166. 1

    Phone 

    Screen
    2

    Manager 

    Screen
    3

    Coding
    Test
    4
    Onsite
    Evals

    View Slide

  167. Stages
    4. Onsite Evals
    • 4-6 hours onsite

    • Fly in, if not local

    View Slide

  168. Stages
    4. Onsite Evals
    • Coding

    • Behavioral

    • System Design

    View Slide

  169. Stages
    4. Onsite Evals
    • Arrive Thursday night

    • Interviews start 9am Friday

    View Slide

  170. Stages
    4. Onsite Evals
    • 9-9:30 - arrival / meet recruiter

    • 9:30-10:20 - meet hiring manager

    • 10:30-11:20 - coding w/ 2 sr engineers

    • 11:30-12:20 - sys design w/ sr architect

    • 12:30-1:30 - lunch w/engineer on team

    • 1:30-2:20 - coding w/ 1 staff engineer

    • 2:30-3:20 - debrief w/ recruiter

    View Slide

  171. View Slide

  172. Stages
    4. Onsite Evals
    • 9-9:30 - arrival / meet recruiter
    • 9:30-10:20 - meet hiring manager

    • 10:30-11:20 - coding w/ 2 sr engineers

    • 11:30-12:30 - sys design w/ sr architect

    • 12:30-1:30 - lunch w/engineer on team

    • 1:30-2:20 - coding w/ 1 staff engineer

    • 2:30-3:20 - debrief w/ recruiter

    View Slide

  173. Stages
    4. Onsite Evals
    • 9-9:30 - arrival / meet recruiter

    • 9:30-10:20 - meet hiring manager
    • 10:30-11:20 - coding w/ 2 sr engineers

    • 11:30-12:30 - sys design w/ sr architect

    • 12:30-1:30 - lunch w/engineer on team

    • 1:30-2:20 - coding w/ 1 staff engineer

    • 2:30-3:20 - debrief w/ recruiter

    View Slide

  174. Stages
    4. Onsite Evals
    • 9-9:30 - arrival / meet recruiter

    • 9:30-10:20 - meet hiring manager

    • 10:30-11:20 - coding w/ 2 sr engineers
    • 11:30-12:30 - sys design w/ sr architect

    • 12:30-1:30 - lunch w/engineer on team

    • 1:30-2:20 - coding w/ 1 staff engineer
    • 2:30-3:20 - debrief w/ recruiter

    View Slide

  175. Stages
    4. Onsite Evals
    • 9-9:30 - arrival / meet recruiter

    • 9:30-10:20 - meet hiring manager

    • 10:30-11:20 - coding w/ 2 sr engineers
    • 11:30-12:30 - sys design w/ sr architect

    • 12:30-1:30 - lunch w/engineer on team

    • 1:30-2:20 - coding w/ 1 staff engineer
    • 2:30-3:20 - debrief w/ recruiter

    View Slide

  176. Examples
    “Given an array of the 100 most common child
    names in 2021, sort them alphabetically”
    “List the top 10 products sold alphabetically on the
    sidebar of a site. Given an array of the top 1,000
    products where the key is their popularity and the value
    is the product name. Return an array.”
    Quicksort

    View Slide

  177. Examples
    “Given an array of the 100 most common child names in 2021, sort them
    alphabetically”
    Quicksort

    View Slide

  178. Examples
    “Given an array of the 100 most common child names in 2021, sort them
    alphabetically”
    const childNames = […];
    return childNames.quicksort();
    Quicksort

    View Slide

  179. Examples
    “List the top 10 products sold alphabetically on the sidebar of a site. Given an
    array of the top 1,000 products where the key is their popularity and the value
    is the product name. Return an array.”
    Quicksort

    View Slide

  180. Examples
    const products = […];
    return products.quicksort()
    .slice(0, 10)
    .quicksort();
    “List the top 10 products sold alphabetically on the sidebar of a site. Given an
    array of the top 1,000 products where the key is their popularity and the value
    is the product name. Return an array.”
    Quicksort

    View Slide

  181. Examples
    const products = […];
    return products.quicksort()
    .slice(0, 10)
    .quicksort();
    “List the top 10 products sold alphabetically on the sidebar of a site. Given an
    array of the top 1,000 products where the key is their popularity and the value
    is the product name. Return an array.”
    Quicksort

    View Slide

  182. 🛠 WORKSHOP
    https://bit.ly/passTechInterview

    On-Site Coding Test

    View Slide

  183. Stages
    4. Onsite Evals
    • 9-9:30 - arrival / meet recruiter

    • 9:30-10:20 - meet hiring manager

    • 10:30-11:20 - coding w/ 2 sr engineers

    • 11:30-12:30 - sys design w/ sr architect
    • 12:30-1:30 - lunch w/engineer on team

    • 1:30-2:20 - coding w/ 1 staff engineer

    • 2:30-3:20 - debrief w/ recruiter

    View Slide

  184. Examples
    System Design

    View Slide

  185. 🛠 WORKSHOP
    https://bit.ly/passTechInterview

    On-Site Sys Design

    View Slide

  186. Stages
    4. Onsite Evals
    • 9-9:30 - arrival / meet recruiter

    • 9:30-10:20 - meet hiring manager

    • 10:30-11:20 - coding w/ 2 sr engineers

    • 11:30-12:30 - sys design w/ sr architect

    • 12:30-1:30 - lunch w/engineer on team
    • 1:30-2:20 - coding w/ 1 staff engineer

    • 3:30-4 - debrief w/ recruiter

    View Slide

  187. Stages
    4. Onsite Evals
    • 9-9:30 - arrival / meet recruiter

    • 9:30-10:20 - meet hiring manager

    • 10:30-11:20 - coding w/ 2 sr engineers

    • 11:30-12:30 - sys design w/ sr architect

    • 12:30-1:30 - lunch w/engineer on team

    • 1:30-2:20 - coding w/ 1 staff engineer

    • 3:30-4 - debrief w/ recruiter

    View Slide

  188. View Slide

  189. View Slide

  190. Offer

    View Slide

  191. Negotiation

    View Slide

  192. Examples
    Career Ladder

    View Slide

  193. Total Comp =
    Salary + Equity + Benefits

    View Slide

  194. View Slide

  195. Parting
    Thoughts

    View Slide

  196. Practice

    View Slide

  197. Examples

    View Slide

  198. View Slide

  199. Resources
    https://randallkanna.com/get-the-ultimate-list/
    https://leetcode.com
    https://levels.fyi
    http://www.crackingthecodinginterview.com https://educative.io

    View Slide

  200. Let’s Work Together
    Wayfair Careers Portal
    https://www.wayfair.com/careers/jobs
    Email me
    [email protected]

    View Slide

  201. Thank You
    @benedmunds
    [email protected]

    View Slide