Optiver interview question

It was hacker rank problem