G-Research Interview Question

brain teaser type. More complicate than usual.