Help me in solving ARRAYSTATE problem

My issue

I can’t Understand the logic someone please try to explain the logic to me

Problem Link: Find Multiset State Practice Coding Problem