Optiver Interview Question

Solving a series of logic gates