Amazon hiring contest 29th March,2020

How to approach this one??
I tried a very basic approach. Didn’t work