Tiger Analytics interview question

Pseudocodes