Wayfair | SWE | OA

Anonymous User
1760
Jun 28, 2024
Jul 24, 2024

The OA is for 50 minutes and only 2 questions were there.

Question 1: 75 marks
You are given a binary matrix(m*n) and a integer K. 0 in the binary matrix represents that you can go to that cell and 1 represents that you can't. You have to go from (0,0) to (m-1,n-1). You can only go to the cells which has 0 in it. You can move in 4 directions and in one move you can go upto k steps in that direction if there is no obstacle(1) on that path. Find the minimum number of moves to reach the end of the matrix.
My Solution: I think I have to solve this using BFS but I used DFS and got Timeout error. 6/15 testcases passed in this problem


Question 2: 50 marks
You are given 2 arrays of string(strs, queries), one of them contains all the strings and the other has queries inside it. You have to answer all the queries, each query has one string and you have to give all the strings in strs which are anagrams of the given string for that query.
My Solution: I solved it by making a map of charmap with all the strings associated with it. All the test cases were passed in this problem.


If there are any other suggestions on these problems. Please post them in comments.

Comments (7)