Optiver Interview Question

It was hacker rank problem