Meta Interview Question

Approach on the finding solution