Hey guys. I was hoping somebody could explain how to proceed ahead with this question.

I can definitely think of a brute force solution to this problem, but given the time constraints, brute force wouldn't work. Could someone please explain the solution approach?

Thanks