About the TC of brute force mentioned in the video

in the video clip in 1:22 time it was mentioned that the time complexity of brute force approach is O (m×n).How is it so?

Hey @Senjuti256
I am not able to access the content
Can u please tell me for which task, the above is mentioned?

basically we need to find whether a particular string of length m is present in a list of n strings.What will be the brute force approach?

Yeah so assume there are n strings with length m
lets assume for example n=2 m=3
aab
aac

and we have to find aad
So we will match to_find string with every other string till they both match completely so in above cases its worst case and will be equal to n*m
So when doing brute force u will write something like this

for(int i=0;i<n;i++){
   for(int i=0;i<m;i++)
    {    if(str[i][j]!=to_match[j])
            break;
         else if(j==m-1)//i.e we reached the end of string 
            return true;
    }

}

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.