Onity Group Interview Question

Solving a puzzle