MInimum Word distance

bhaiya i have not understood the brute force approach of this problem

pls prove me pseudocode of brute force approach

@amaaanahmedkhan987 just compare every string with other and find the distance between them.
when you compare the two strings check if one of them is w1 and other w2.
is it ok? any doubts?

what i am doing wrong pls tell me

@amaaanahmedkhan987 the function seems correct
your full code?

@amaaanahmedkhan987 its working fine whats the problem?
if its not passing all cases thats because its bruteforce

it is giving 5 ouptut for this test case :
5
practice makes perfect coding makes
coding practice
but it should give 3

ok wait let me check
its because you are checking if first string came then iterating in front of it while the other string is behind

so pls help me to modify my code

@amaaanahmedkhan987 check this updated


is it clear? just did the reverse too

thanks got it now i understood

np bro just mark it as resolved and hit like if you want :smiley:

1 Like

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.