Expedia SDE-2 Bangalore — puzzle + matrix + tree; reject
I had Expedia Group Onsite Interview (conducted virtually) for SDE 2 role, Bangalore location. The interview lasted for 1.5 hrs.
Below are the questions -
- Puzzle -> There are 3 Jars. One jar contains only orange, one jar contains only apple and the remaining jar contains mix of apple and orange. The mix need not be half half. All the jars given are mislabelled. Label the jars properly. Find the minimum no of fruits you need to take out to label all the jars correctly.
- Given a matrix, row wise sorted and column wise sorted. Given a target element search it in the matrix. If the element is found in matrix, return its indices or return Not Found. Return should be string type.
- Given a binary tree. Find the maximum height of the binary tree.
My answers in the interview -
-
Puzzle -> ... Solution -> Keep in mind all are mislablled. Jar 2 cannot be mix of orange and apple. Hence take one fruit out of it. Lets say the fruit is orange. Hence jar 2 is definitely orange. Now if jar 2 is orange, that means jar 3 is definitely not orange it can be mix or only apple. Now jar 1 also cannot be only apple as its mislabelled. Hence i can say that jar 3 can be apple and jar 1 can be mix. Hence minimum no of fruits required is 1.
-
Run a loop for total no of rows. Row wise its sorted and column wise also sorted. Check for every row if the target element is >= first element of row and <= last element of that row. If so, do a binary search on the row elements to find the column index. Return the row and column in string format. If not found, go to next row.
-
Its a simple leetcode question to find max depth/height of binary tree. I used simple dfs recursion for the solution.
Verdict - Not selected for further rounds.
The loop · 1 round
3 mislabelled jars puzzle (min fruits to relabel); search row/column-sorted matrix; max height of binary tree