CONVSTR may lunchtime

This is my code for the ques CONVSTR in may lunch time 2020.
I am getting a wrong answer.I have tried debugging my code but have been unable to find a test case for which it fails. Please help.
I have taken both strings and mapped all the character of each string to a vector that contains the indices on which these characters occur.Then i have found the greatest character in string q(lets name it x) and seen all its occurances in q and then i have found this x in p and my subset becomes all the occurances of x in q plus occurance of that character in p. Now i have also taken care of the fact that the index of occurance of x in p can be a part of the vector of occurances of x in q in this case the output subset becomes the occurances of x in q. I have stored the ans in an array of vectors and each vector is the subset . In this way i go to all characters of q in descending order and store the answers in my array of vector .Also i have included a lot of comments in my code for you to understand

are you updating the first string after each operation?
(I am not familiar with vectors and all)

No i am not but that wont be required infact after mapping all the characters of both the strings i am not even using string p.