Solve Three Coding Interview Problems
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
The interview included three coding tasks:
1. **Common ancestor in an N-ary tree**
You are given the root of an N-ary tree and two target nodes. Determine whether the two nodes share a common ancestor, and if they do, return their lowest common ancestor. If either node does not exist in the tree, return `null`.
2. **Merge two sorted interval lists**
You are given two sorted lists of non-overlapping intervals:
- `intervals1 = [[1, 2], [3, 4]]`
- `intervals2 = [[1, 3], [7, 8], [9, 10]]`
Merge all intervals from both lists into one sorted list of non-overlapping intervals. For the example above, the output should be:
`[[1, 4], [7, 8], [9, 10]]`
3. **Maximum-length subset of words with unique letters**
You are given a list of lowercase words. Choose a subset of words such that no letter appears more than once across the entire chosen subset. Return the maximum possible total number of characters in the chosen subset.
For all three tasks, explain the algorithm and analyze time and space complexity.
Quick Answer: This set of tasks evaluates proficiency in data structures and algorithms, covering tree traversal and lowest common ancestor reasoning, interval merging and overlap resolution, and combinatorial subset selection under uniqueness constraints.