Tesla interview question

Data structures. (VERY) Easy leetcode