The above approach is a O(n^2) solution, There is a better solution in O(nlogn) using binary search and with space complexity O(1) and then there is even better solution using dp with tc = O(n) and space O(n)
@@Practice_dsa_together first it will check for n length palindrome, if it is not pal. then it will check for n-1 length pal. like wise (n-2) , (n-3) ...... 3, 2 so the time complexity will be O(n^2) in best case it will be O(n) .
In Video you said- answer will be length of (N - longest palindromic substring). for test case s = 'BAAA' it will fail as per your explanation ans should be 1 but actual answer is 3 for above case?? pls correct me if I am wrong or mis interpreted your logic
How can you surely say that answer will be n-(length of LPS) let's say input is xxaxxa so acc to you answer will be 6-(lenbgth of "xxaxx")=1 but the expected answer is 2.
i watched 4 to 5 videos on this problem but i was not satisfied with the solutions there or they seemed difficult but now i am satisfied..best explanation👍
This logic is wrong,please make the logic which can apply on all the test cases ,you might forget some test cases,but still appreciate your work madam ji,and you have hide your submission while making video.
This logic giving TLE in c++
that's because approach seems to be O(n2)
@@QuantYogi yes this is O(n^2) approach. She has just twisted it.
The above approach is a O(n^2) solution,
There is a better solution in O(nlogn) using binary search and with space complexity O(1)
and then there is even better solution using dp with tc = O(n) and space O(n)
how is it o(n2)
@@Practice_dsa_together She is resetting the value of i to 0 if the chars are different. So in the worst case, it will restart for every char.
she is updating j with the trim value continuously in case of characters mismatch@@Practice_dsa_together
As it's checking for for (n-1+n-2+n-3---------1) we are only opting out the last character basicaly just checking sequence from 0th index .
yeah Actualy i don't know why its submitting as the testcases constraint is 10^6 which will result in 10^12 operations>4*10^8.
@Study with Saumya , try submitting it.
Your code will give TLE.
lmao
TC is O(n^2). if we use KMP algo then TC will O(n).
how is it o(n2)
@@Practice_dsa_together first it will check for n length palindrome, if it is not pal. then it will check for n-1 length pal. like wise (n-2) , (n-3) ...... 3, 2 so the time complexity will be O(n^2) in best case it will be O(n) .
Why does the same code in C++ give TLE?
hmm yrr whi
In Video you said- answer will be length of (N - longest palindromic substring).
for test case s = 'BAAA' it will fail
as per your explanation ans should be 1 but actual answer is 3 for above case??
pls correct me if I am wrong or mis interpreted your logic
Yes you are right 👍 it fails at this test case
it will fail for 'BANANA' aswell
I'm new in dsa and i got your explaination very easily can you please make a video on how to learn dsa like any roadmap...
TLE.......please upload the optimised approach
How easily u solved this question is Amazing !!
TLE mam please tell us how to optimize this code
Hii somya ...nice tutorial.... my all douts is cleared..... thank you
Glad it helped 😊
@@TechWithSaumya are you do DSA daily....can we practice on daily basis.....i don't have any friend circle to practice DSA
😂
How can you surely say that answer will be n-(length of LPS)
let's say input is xxaxxa
so acc to you answer will be 6-(lenbgth of "xxaxx")=1 but the expected answer is 2.
whats time complexity of your code ?
Don't you think your code time complexity is O(n^2) in the worst case..
This can be solved using LPS array in O(n) time
Carryon mam like this... It will help us a lot.. And thnq so much mam
Glad it helped 😊
Time complexity is O(n^2). It will give TLE. :(
TLE this solution is not optimised
the above code won't pass all the test cases
Aap bhee striver ke student ho ?:I hope u all are doing extremely well !!
ThankYou ma'am
Glad it helped 😊
it will give tle
thanks :)
Happy to help
can any one provide the test case that fail bcz of TLE
you will get TLE with this solution will have to use DP to optimize it further
I love you what a easy solution 🤩🤩🤩🤩🤩🤩🤩🥰🥰 thanks you
Glad it helped 😊
i watched 4 to 5 videos on this problem but i was not satisfied with the solutions there or they seemed difficult but now i am satisfied..best explanation👍
Glad it helped
Is it always follow O(n) time complexity??
@@ShivamSingh-ne3en No bro. How is it even following O(N) complexity.
It is giving TLE on Interview bit. It is easy but not efficient;
bro its give TLE :(
ig TC - O(n^2). Not an optimized solution
how is it o(n2)
This logic is wrong,please make the logic which can apply on all the test cases ,you might forget some
test cases,but still appreciate your work madam ji,and you have hide your submission while making video.
Thank you mam . It is a great explanation . Keep helping us and your chanel grow quickly ❣❣❣
Thanks for the appreciation 😊😊
😅😅
Mam please use open Board 🙏 and explain logic not code please mam
Thanks mam for efforts
TLE
it is giving tle
ye O(n^2) approach hai.... janta ko bevkoof mat banao galat solution dalke
how is it o(n2)
Don't you think your code time complexity is O(n^2) in the worst case..