Panda Guru LogoPanda
Guru

Wayfair Interview Questions

Round 1

Questions:

Question

  1. Basic
    This one was to find pairs with target difference in an array.
    Input:
[1, 2, 3, 4, 5] target = 2

Output:

3
  1. Intermediate
    It was a subsequence question in which we had to find minimum sum subsequence such that
    sub[0] < sub[1] > sub[2] in all length = 3 subsequences.

  2. Advanced
    We are given 3 integers n, m and totalCost.
    totalCost is the number of swaps that happen during linear search of maximum number in array.

x = arr[0] totalCost = 0 for i in range(len(arr)): if arr[i] > x: x = arr[i] totalCost += 1

We had to find the number of arrays of totalCost equal to the given totalCost such that each array is of length n and arr[i] <= m where i is from 0 to n.

Candidate's Approach
  1. For the basic question, I solved it by making a dictionary of counts of numbers and then added the target to each element of the array to check if it exists in the dictionary and returned the result of the summation of counts of existing arrays.

  2. For the intermediate question, I tried creating an array of all subsequences of length 3 and traversed through them to find the one with the minimum sum but kept reaching recursion depth exceeded for half the test cases.

  3. For the advanced question, I tried creating all possibilities and then storing them in an array to calculate total cost and return the answer, but I couldn't even pass a single test case as I didn't leave myself enough time for the last test case.

Interviewer's Feedback

No feedback provided.