Solve coding and AI-assisted tasks
Company: Meta
Role: Backend Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
This interview included several algorithm problems across a phone screen, onsite coding, and an AI-assisted coding round. Solve the following tasks:
1. **Right-side visibility in a skyline**: Given an integer array `heights`, where `heights[i]` is the height of the `i`-th building from left to right, return the indices of buildings that can see the ocean on the right. A building can see the ocean if every building to its right is strictly shorter. Return the indices in increasing order, and be prepared to discuss edge cases.
2. **Print an immutable linked list in reverse**: You are given the head of a singly linked list whose nodes expose only `getNext()` and `printValue()` methods. You may not modify the list. Print the values from tail to head. First discuss multiple approaches, then implement the simplest correct approach.
3. **Find a common ancestor with parent pointers**: You are given two nodes in a tree. Each node has a pointer to its parent. Return their lowest common ancestor.
4. **Remove the fewest invalid parentheses**: Given a string containing lowercase letters and parentheses, remove the minimum number of parentheses so that the result is valid. Return any valid result.
5. **AI-assisted maze search**: In a separate AI-enabled coding round, solve a grid-maze problem. Given a 2D grid containing a start cell `S`, an end cell `E`, open cells `.`, and walls `#`, determine whether `E` is reachable from `S` using 4-directional movement. Be ready for common follow-ups such as returning the shortest path length or reconstructing one valid path.
Quick Answer: This set evaluates algorithmic problem-solving across arrays, immutable linked-list interfaces, parent-pointer tree traversal, string validity via minimal edits, and grid-based pathfinding including an AI-assisted maze search, testing data-structure knowledge, complexity reasoning, and handling of constrained APIs.