Leetcode | Biweekly Contest 140 | B | C | Editorial | 3301 | 3302 | Simple Explanation with Code.

  Рет қаралды 1,757

Pretest Passed

Pretest Passed

Күн бұрын

Пікірлер: 69
@pretestpassed157
@pretestpassed157 3 ай бұрын
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])
@abhayurmaliya6801
@abhayurmaliya6801 3 ай бұрын
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.
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@gangsta_coder_12
@gangsta_coder_12 3 ай бұрын
Excellent explanation👍
@abhinay.k
@abhinay.k 3 ай бұрын
thanks, for the excellent explanation.
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@preetambal7443
@preetambal7443 3 ай бұрын
Very well explained . It’s always easy understand with some graphical explanation . Great job buddy👏
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@pratiksarangi4071
@pratiksarangi4071 3 ай бұрын
Mind blowing solution for C. Thanks bro!!!
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@vinayjoshi8714
@vinayjoshi8714 3 ай бұрын
Great explanation bhaiya ❤❤❤
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@harshmittal6461
@harshmittal6461 3 ай бұрын
What a nice explanation, I respect your efforts!!
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@shubhamrai8673
@shubhamrai8673 3 ай бұрын
Thanks Bhaiya Samjh aa gya problem C and suffix approach for problem C . Khud se implement kiya suffix approach ko
@pretestpassed157
@pretestpassed157 3 ай бұрын
Great, keep it up.
@MokshKajaliya-n9l
@MokshKajaliya-n9l 3 ай бұрын
Very good explaination of C . Keep up the good work bro 👏
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@sanyamjain7058
@sanyamjain7058 3 ай бұрын
noice explanation keep going!
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@Simar7Singh
@Simar7Singh 3 ай бұрын
great explanation bhai
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@piyush.28
@piyush.28 3 ай бұрын
Bahut acche se explain kiye aapne
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@yereneager
@yereneager 3 ай бұрын
Kya samjhaate ho bhaiya, thanks ❤ Btw glti se channel name Preetesh Prasad pdh lia tha🥸
@pretestpassed157
@pretestpassed157 3 ай бұрын
😂. Thankyou
@gyanikumari4973
@gyanikumari4973 3 ай бұрын
Nice explanation 🎉🎉
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@harshalyallewar
@harshalyallewar 3 ай бұрын
thanks bro, appreciate
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@divyachaudhary8669
@divyachaudhary8669 3 ай бұрын
Superb explanation😮
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@tempbot7190
@tempbot7190 3 ай бұрын
Great Explanation!
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@nanddaclub3972
@nanddaclub3972 3 ай бұрын
C thoda complicated tha lekin samaj agya 🙏
@pretestpassed157
@pretestpassed157 3 ай бұрын
Nice
@ayushmishra1207
@ayushmishra1207 3 ай бұрын
thanks
@reactcode9148
@reactcode9148 3 ай бұрын
Best explanation
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@GauravDuseja-t6q
@GauravDuseja-t6q 3 ай бұрын
Best Explanation bhaiya
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
@satendra6200
@satendra6200 3 ай бұрын
Amazing explanation brother :) Please keep on uploading such contents Are you from Bihar bro ?
@pretestpassed157
@pretestpassed157 3 ай бұрын
Yes, thankyou.
@workonedu3535
@workonedu3535 3 ай бұрын
Thanku u
@pretestpassed157
@pretestpassed157 3 ай бұрын
Welcome
@StockMarketbysahil
@StockMarketbysahil 3 ай бұрын
1 semester student starting se kaise cp kare ispe video bana digiye guide kar digiye please sir
@ronakkriplani1838
@ronakkriplani1838 3 ай бұрын
kab se wait kar rahe the
@uhdfku8915
@uhdfku8915 3 ай бұрын
Bhaiya leetcode 3303 bhi explain kr do pls 🙏
@atharvameher5880
@atharvameher5880 3 ай бұрын
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
@vinitverma1741
@vinitverma1741 3 ай бұрын
Bhaiya please upload weekly contest solution
@pretestpassed157
@pretestpassed157 3 ай бұрын
I haven't participated in a weekly contest, so I wasn't able to upload.
@kishansinghc1581
@kishansinghc1581 3 ай бұрын
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!!
@pretestpassed157
@pretestpassed157 3 ай бұрын
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.
@kishansinghc1581
@kishansinghc1581 3 ай бұрын
@@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
@pretestpassed157
@pretestpassed157 3 ай бұрын
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.
@vinayjoshi8714
@vinayjoshi8714 3 ай бұрын
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
@workonedu3535
@workonedu3535 3 ай бұрын
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.28
@piyush.28 3 ай бұрын
Hamlog priority queue v to use kar sakte hai esme
@dakshjadhav4595
@dakshjadhav4595 3 ай бұрын
bro your B solution is not working
@pretestpassed157
@pretestpassed157 3 ай бұрын
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])
@topbard2889
@topbard2889 3 ай бұрын
Bhaiya I can consistently solve 2 questions but not 3rd, can you share some resources guide for practice.
@pretestpassed157
@pretestpassed157 3 ай бұрын
I will suggest you to start practicing all the c problems of the leetcode contest.
@anant-strong
@anant-strong 3 ай бұрын
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]
@pretestpassed157
@pretestpassed157 3 ай бұрын
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.
@Abhay14
@Abhay14 3 ай бұрын
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; } };
@pretestpassed157
@pretestpassed157 3 ай бұрын
Nice.
@Abhay14
@Abhay14 3 ай бұрын
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
@vibhoosrivastava2571
@vibhoosrivastava2571 3 ай бұрын
best explanation
@pretestpassed157
@pretestpassed157 3 ай бұрын
Thankyou
Путин ответил на ультиматум Трампа
7:25
Diplomatrutube
Рет қаралды 1 МЛН
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН
БОЙКАЛАР| bayGUYS | 27 шығарылым
28:49
bayGUYS
Рет қаралды 1,1 МЛН
IIT-JEE Toppers: Where Are They Now?
15:52
Mohak Mangal
Рет қаралды 3,3 МЛН
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 240 М.
Why 99.6% of Indians Aren't Rich
18:22
Mohak Mangal
Рет қаралды 2,6 МЛН
How do Graphics Cards Work?  Exploring GPU Architecture
28:30
Branch Education
Рет қаралды 3,1 МЛН
LOFI Quran • Get Instant Relief From Mental Fatigue and Overthinking ✦ NOOR
3:04:08
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН