Meta | Onsite | E5/E6 | Offer
Anonymous User
4121

Product Architecture
An API(A function, not an HTTP API) for Meta software developers to translate a given text in any language to English.

Coding Round#1
1- Variation of https://leetcode.com/problems/simplify-path/ [two inputs instead of one, currennt directory and cd command]
2- https://leetcode.com/problems/interval-list-intersections/

Coding Round#2
1- https://leetcode.com/problems/diameter-of-n-ary-tree/
2- In an N*M matrix, each cell represents either an empty room, an obstacle or a robot. Find the farthest rooms from the robot's cell.

I did BFS using a single Q, somewhat similar to the below snippet, but the interviewer didn't seem to follow the logic behind having a for loop insite the while loop, and seemed to have an understanding that the outer while loop was good enough to implement BFS. It's a clear bad luck and pretty sure they are not moving forward with me.
Was able to solve rest of the problems with optimized time and space complexities.

            while (!q.isEmpty()) {
                        steps++;

                        for (int level = q.size(); level > 0; --level) {
                            int[] curr = q.poll();

                            for (int[] dir : dirs) {
                                int nextRow = curr[0] + dir[0];
                                int nextCol = curr[1] + dir[1];

                                // For each cell with the value equal to empty land value
                                // add distance and decrement the cell value by 1.
                                if (nextRow >= 0 && nextRow < rows &&
                                    nextCol >= 0 && nextCol < cols &&
                                    grid[nextRow][nextCol] == emptyLandValue) {
                                    grid[nextRow][nextCol]--;
                                    total[nextRow][nextCol] += steps;

                                    q.offer(new int[]{ nextRow, nextCol });
                                }
                            }
                        }
                    }
Comments (10)