Leetcode Data Structure Question