Google interview question

Basic Leetcode D Structures and Algorithms question