Please help. I am sharing my solution, feel free to ask if you need me to explain my approach.
Doubt in leetcode problem, code not working
Hey @anshufirefox
if(allowed.find(words[i][j])!=std::string::npos)
if string is not found then it returns that
Thanks, it works fine now. Btw, can I optimize my solution from O(n^2) to a better time complexity? Even in terms of memory
Hey @anshufirefox
your code is O(nmx) where n is list size and m is max word size and x is allowed string size
It can be optimized further to O(nm) by creating a freq map for allowed string
Then it cant be optimized further
Can you please share the code of the freq map approach?
Here
Thank you, understood it
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.