Game of tiles approach

I want to know how to approach this problem. I tried to do but I was not able to correctly solve it.

Hi… sry but we cant help u during an ongoing contest or any hiring challenge… pls don’t send it again or ur account can also be blocked…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

This question is from hiring contest that is already over and I am asking you how can i solve it. So that it will help me in future.