Meta·Software Engineer·Onsite - Coding / Algorithms
- Given a sorted integer array, modify it in-place so each distinct value appears exactly once at the front, preserving order. Return the prefix length. O(1) space, O(n) time. Follow-up: what if each value could appear up to k times?
- Find the length of the longest strictly increasing path in an integer grid, where moves are up/down/left/right. How would you reconstruct the actual path, and how do you handle recursion depth on very large inputs?
- Design a friend recommender for a social graph. Implement getCandidates (friends-of-friends excluding direct friends), recommendRandom (uniform random pick), and recommendTopK (ranked by mutual friend count, ties broken by user ID). Then discuss how you'd extend the scoring in production.
“Two-pointer setup, pretty classic.”