ByteDance Interview Question

What is the best data structure to solve this problem?