Link expired, but I guess just making set, clearing it for every query, and then inserting elements and return size of set, would give AC.
I didn’t understand how it will work. Because I am storing the queries in the MultiSet.
Basically Mo’s Algorithm.
Source Code -