why it will not give tle . at 19:19 the while of stack can give tle . assume u are at n-1 the element (assuming 0 base indexing) and all the elements before it aree in stack (element from 0 to n-2 indexes) and they all have a[i] greater than b[n-1] . so the removal of all elements would be o(n-1) =o(n) [approx] . also the for loop above is of o(n) . so total time complexity :- o(n square). plss help
Hello bro, Good to see that u r continuing this series. Hope u r doing well. I have a question, I started DP about 2 months ago and from the start I use bottom-up approach to solve DP. I dont think of top-down approach first, I just start thinking bottom-up directly coz it feels more intuitive for me to first tackle base case and the create soln over that base. But sometimes I find difficulty finding the dimension of state, like what parameter the state depend on and sometimes transition. Should i first think and start doing top-down or I can go on with bottom-up indefinitely. Thnx for your videos!
Hi bro, Most of times, bottom-up approach works better. There are just some rare cases where you need to do backtrack and hence need to do top-down approach. So, I'll recommend you to feel free to use bottom-up.
Thanks for doing this , please extend this list
why it will not give tle . at 19:19 the while of stack can give tle . assume u are at n-1 the element (assuming 0 base indexing) and all the elements before it aree in stack (element from 0 to n-2 indexes) and they all have a[i] greater than b[n-1] . so the removal of all elements would be o(n-1) =o(n) [approx] . also the for loop above is of o(n) . so total time complexity :- o(n square).
plss help
Hello bro, Good to see that u r continuing this series. Hope u r doing well.
I have a question, I started DP about 2 months ago and from the start I use bottom-up approach to solve DP. I dont think of top-down approach first, I just start thinking bottom-up directly coz it feels more intuitive for me to first tackle base case and the create soln over that base. But sometimes I find difficulty finding the dimension of state, like what parameter the state depend on and sometimes transition. Should i first think and start doing top-down or I can go on with bottom-up indefinitely.
Thnx for your videos!
Hi bro,
Most of times, bottom-up approach works better. There are just some rare cases where you need to do backtrack and hence need to do top-down approach. So, I'll recommend you to feel free to use bottom-up.
@@CPwithShayan Thnx for the reply mate! 🫡
From which country you are bro
Dp ❤❤
Do some problems from timus 🤗
Sure, I'll try.