Ransom notes string problem

I am trying to make a char arrays if R[i] == M[j] then i will insert into the result char array.
But the things it will not works for another test case like bab , acbcb because i am incrementing j each time how to actually mark the char i have visited so i can’t use it another time.
Hope u got me!:slightly_smiling_face:

This problem can be solved recursively i don’t about the hashmap just searching on google they are using the hashmap to solve this problem