if(maximumHeight[i]>=maximumHeight[i+1]) { maximumHeight[i]=maximumHeight[i+1]-1; } In the problem B, use this condition. By mistake while making video i used the condition if(maximumHeight[i]==maximumHeight[i+1])
@abhayurmaliya68013 ай бұрын
Nice Explaination !!!, Directly not jumping into the solution and developed approach first was nice. Just continue making these videos will watch more. Subscribed as well.
@pretestpassed1573 ай бұрын
Thankyou
@gangsta_coder_123 ай бұрын
Excellent explanation👍
@abhinay.k3 ай бұрын
thanks, for the excellent explanation.
@pretestpassed1573 ай бұрын
Thankyou
@preetambal74433 ай бұрын
Very well explained . It’s always easy understand with some graphical explanation . Great job buddy👏
@pretestpassed1573 ай бұрын
Thankyou
@pratiksarangi40713 ай бұрын
Mind blowing solution for C. Thanks bro!!!
@pretestpassed1573 ай бұрын
Thankyou
@vinayjoshi87143 ай бұрын
Great explanation bhaiya ❤❤❤
@pretestpassed1573 ай бұрын
Thankyou
@harshmittal64613 ай бұрын
What a nice explanation, I respect your efforts!!
@pretestpassed1573 ай бұрын
Thankyou
@shubhamrai86733 ай бұрын
Thanks Bhaiya Samjh aa gya problem C and suffix approach for problem C . Khud se implement kiya suffix approach ko
@pretestpassed1573 ай бұрын
Great, keep it up.
@MokshKajaliya-n9l3 ай бұрын
Very good explaination of C . Keep up the good work bro 👏
@pretestpassed1573 ай бұрын
Thankyou
@sanyamjain70583 ай бұрын
noice explanation keep going!
@pretestpassed1573 ай бұрын
Thankyou
@Simar7Singh3 ай бұрын
great explanation bhai
@pretestpassed1573 ай бұрын
Thankyou
@piyush.283 ай бұрын
Bahut acche se explain kiye aapne
@pretestpassed1573 ай бұрын
Thankyou
@yereneager3 ай бұрын
Kya samjhaate ho bhaiya, thanks ❤ Btw glti se channel name Preetesh Prasad pdh lia tha🥸
@pretestpassed1573 ай бұрын
😂. Thankyou
@gyanikumari49733 ай бұрын
Nice explanation 🎉🎉
@pretestpassed1573 ай бұрын
Thankyou
@harshalyallewar3 ай бұрын
thanks bro, appreciate
@pretestpassed1573 ай бұрын
Thankyou
@divyachaudhary86693 ай бұрын
Superb explanation😮
@pretestpassed1573 ай бұрын
Thankyou
@tempbot71903 ай бұрын
Great Explanation!
@pretestpassed1573 ай бұрын
Thankyou
@nanddaclub39723 ай бұрын
C thoda complicated tha lekin samaj agya 🙏
@pretestpassed1573 ай бұрын
Nice
@ayushmishra12073 ай бұрын
thanks
@reactcode91483 ай бұрын
Best explanation
@pretestpassed1573 ай бұрын
Thankyou
@GauravDuseja-t6q3 ай бұрын
Best Explanation bhaiya
@pretestpassed1573 ай бұрын
Thankyou
@satendra62003 ай бұрын
Amazing explanation brother :) Please keep on uploading such contents Are you from Bihar bro ?
@pretestpassed1573 ай бұрын
Yes, thankyou.
@workonedu35353 ай бұрын
Thanku u
@pretestpassed1573 ай бұрын
Welcome
@StockMarketbysahil3 ай бұрын
1 semester student starting se kaise cp kare ispe video bana digiye guide kar digiye please sir
@ronakkriplani18383 ай бұрын
kab se wait kar rahe the
@uhdfku89153 ай бұрын
Bhaiya leetcode 3303 bhi explain kr do pls 🙏
@atharvameher58803 ай бұрын
I've done DP from striver, I know normal approach of Memoization -> Tabulation. Sir from where can I learn DP such that I do tabulation directly? I see most youtubers doin DP problems direct tabulation
@vinitverma17413 ай бұрын
Bhaiya please upload weekly contest solution
@pretestpassed1573 ай бұрын
I haven't participated in a weekly contest, so I wasn't able to upload.
@kishansinghc15813 ай бұрын
In question C, if word1 = 'aaa' and word2 = 'aab' then your maxSuffix = [0,0,0] then how will you ensure that you can do one changing operation here and suffix string will give you the matching string. Although , great explanation!!
@pretestpassed1573 ай бұрын
As our motto will always be to pick the minimum index, so assign two pointer i and j with value 0 in word1 and word2. Now I will check if word1 [i] == word2[j], and they are equal so we will push this i index to our ans vector and increment both of them now i will become 1 and j will become 1 and we will check for the same. And they are equal so again we will push back the value of i to our ans vector, and i will become 2 and j will become 2. Now if we will check is the value of word1 at index i and word2 at index j are equal, then it will give me false, now we will check for the the next conditions that can we apply one operation on it. Then there is the possibility to apply because the remaining suffix length in word2 is now zero, and we will find the maxisuffix[i+1]>=0 so it will give true so we can do this operation. That's why I initialised the maxsuffix vector with the size of n+1. I think your doubt is clear now.
@kishansinghc15813 ай бұрын
@@pretestpassed157 sorry but its still unclear, my question is if word1 and word2 are the above mentioned words , then while calculating maxSuffix = [0,0,0]. because your i and j are poitning toward the last and then coming to the first.So, if the last value of word2 is not present in word1 then your i will reach i
@pretestpassed1573 ай бұрын
Yes, our max suffix is [0,0,0], so these means that we can use that one operation only at the last index of both the string and even we are doing the operation for the last index only. I would suggest you, once dry run my code for your given test case, you will get your answer.
@vinayjoshi87143 ай бұрын
Bhaiya i am just starting the contest i have given just 3 contest till date and was just able to solve only 1 question 😢 please give me some advice so that i can solve atleast 3 questions
@workonedu35353 ай бұрын
Bhai I attended 70+ contests still I am on 1st and try to solve second one ,but good thing is that now I am able to attempt 2ñd one so keep trying to solve more and more this is the best way to learn
@piyush.283 ай бұрын
Hamlog priority queue v to use kar sakte hai esme
@dakshjadhav45953 ай бұрын
bro your B solution is not working
@pretestpassed1573 ай бұрын
if(maximumHeight[i]>=maximumHeight[i+1]) { maximumHeight[i]=maximumHeight[i+1]-1; } In the problem B, use this condition. By mistake while making video i used the condition if(maximumHeight[i]==maximumHeight[i+1])
@topbard28893 ай бұрын
Bhaiya I can consistently solve 2 questions but not 3rd, can you share some resources guide for practice.
@pretestpassed1573 ай бұрын
I will suggest you to start practicing all the c problems of the leetcode contest.
@anant-strong3 ай бұрын
i think your B solution is incorrect. It is failing on the testcase: [6,6,6,3,7,2,6,5], if I traverse your code for this solution, first sorting so, 2,3,5,6,6,6,6,7 then we change the (n-3)th 6 to 5, then if we compare (n-3)th which is now 5 to (n-4)th which is 6 it'll simply pass without modifying the array in short the modified array looks like 2 3 4 5 6 5 6 7, which is not correct. class Solution { public: long long maximumTotalSum(vector& maximumHeight) { long long n = maximumHeight.size(); sort(maximumHeight.begin(),maximumHeight.end()); for(int i = n-2;i>=0;i--){ if(maximumHeight[i]==maximumHeight[i+1]){ maximumHeight[i] = maximumHeight[i+1]-1; } } long long sum = 0; if(maximumHeight[0]
@pretestpassed1573 ай бұрын
My check condition is different from what you have written. if(max[i]>=max[i+1] then you will do the operation otherwise, remain it unchanged.
@Abhay143 ай бұрын
my solution after seeing your explaination( without seeing your solution ) class Solution { public: vector validSequence(string word1, string word2) { int m=word1.size(), n=word2.size(); vectorsuffix(m, 0); int i=m-1, j=n-1, cnt=0; while(i >= 0 && j >= 0){ if(word1[i] == word2[j]){ cnt++; j--; } suffix[i] = cnt; i--; } while(i >= 0){ suffix[i--] = cnt; } vectorans; bool flag = false; i=0, j=0; while(i < m && j < n){ if(word1[i] == word2[j]){ ans.push_back(i); i++; j++; } else{ if(!flag && i < m-1 && suffix[i+1] >= n-j-1){ ans.push_back(i); flag = true; i++; j++; } else{ i++; } } } if(ans.size() != n) return {}; return ans; } };
@pretestpassed1573 ай бұрын
Nice.
@Abhay143 ай бұрын
kya explaination h bhai C vale me maine 3-D dp lgga di socha 3 value change ho rhi h class Solution { public: vector dp; bool solve(int i, int j, string& word1, string& word2, int count, vector& ans) { if (j == word2.size()) return true; if (i == word1.size() || count > 1) return false; if (dp[i][j][count] != -1) return dp[i][j][count]; if (word1[i] == word2[j]) { ans.push_back(i); if (solve(i + 1, j + 1, word1, word2, count, ans)) return dp[i][j][count] = true; ans.pop_back(); } if (count == 0) { ans.push_back(i); if (solve(i + 1, j + 1, word1, word2, count + 1, ans)) return dp[i][j][count] = true; ans.pop_back(); } if (solve(i + 1, j, word1, word2, count, ans)) return dp[i][j][count] = true; return dp[i][j][count] = false; } vector validSequence(string word1, string word2) { vector ans; dp = vector(word1.size(), vector(word2.size(), vector(2, -1))); if (solve(0, 0, word1, word2, 0, ans)) return ans; return {}; } }; 779 test case pr error de diya