G-Research Interview Question

For the algorithm question they asked Leetcode question 135.