I am unable to understand the brute force approach kindly explain it and tell why its complexity is O(n^2).
First Non Repeating character problem
Sir this question is in video content Queue 07 ,
Input : aabccbcd
output: a -1 b b b -1 -1 d
In the video there is a brute force approach i am unable to understand.
Sir i have shared the question , it would be helpful if u could tell the o(n^2) brute force approach as told in the video , the optimized approach i have understood , the same optimized approach is used in this link.
Sir kindly reply , i did not understand the brute force approach O(n^2) properly , but have tried to implement it , kindly correct the code as its not giving correct output.
hi,
refer this for better understanding ->
Can you please tell that is there a way to do the problem like i have attemped in the code shared above , something like this was explained in the course as the brute force approach which i couldn’t understand how to implement otherwise the O(n) approach i have understood completely and my doubt is clear.
okay… yes ur brute force approach is correct only, but why are u restricting the contraints…
like this–>
char arr[9];
for(int i=0;i<8;i++)
due to this it wont run on all test cases…
Sir actually my brute force code is not giving correct output ,this question is covered in the video and not in challenges , it was explained the with the input : aabccbcd , so i took the character array of size 9 to store the input .
@ujj1804_1156aee80205d0bf
corrected code -->
here was the mistake… instead of arr[j], u were writing arr[i]
Sir thank you very much , i am very grateful to you. Doubt clear.
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.