Question d’entretien chez VNG Corporation

Leet code problem, Data structure and algorithm question