VNG Corporation Interview Question

Leet code problem, Data structure and algorithm question