Lecture 30: Trapping Rain Water || 3 SUM || 4 SUM

  Рет қаралды 45,306

Coder Army

Coder Army

Күн бұрын

In Array, Today we learn about Trapping Rain Water || Triplet Sum in Array || 4 SUM
1: Trapping Rain Water: leetcode.com/p...
2: 3 SUM: practice.geeks...
3: 4 SUM :practice.geeks...
4: Array 3 Pointers: www.interviewb...
HomeWork Sheet: drive.google.c...
Join Our Whatsapp Channel: whatsapp.com/c...
Day 40/180, #180daysofcode #180 hard
We have made a whole video in c++, How to solve pattern print problem. We explained everything with the help of code.
We are doing 180 days challenge and going to complete the whole course within the duration with quality content on KZbin. I am on the mission to create a tech revolution in our country and in upcoming future we want to create a tech which will create many jobs in India.
Video will come on Mon-Fri at 6am in the morning
CoderArmy Website (Buy premium feature at 99 Only for 6 months): www.coderarmy.in
Premium Feature includes:
1: Doubt Support
2: Mentorship session
3: Placement Support to Top Students
4: Resume and Linkedin Profile Building
5: Coding contest twice a month
6: Course completion Certificate
7: Home work Discussion
DSA Course for free
C++ Free Course
Rohit Negi DSA Course C++
Coder Army DSA Course c++
Function in C++
Pass by value.
Pass by reference
C++ important topics
connect to me on Instagram: rohit978.page....
Linkedin: rohit978.page....
Telegram: rohit978.page....

Пікірлер: 258
@CoderArmy9
@CoderArmy9 Жыл бұрын
Hard Concept ab easy lag rhe hai?
@newglobal2056
@newglobal2056 Жыл бұрын
Ji bhaiya 🙏🙏🙏❤️❤️
@vivektechtuber204
@vivektechtuber204 Жыл бұрын
Thodi problem ho rhi h but we manage 😌
@krishnasharma3018
@krishnasharma3018 Жыл бұрын
Ji bhaiya ❤
@AbhishekKumar-lu3lp
@AbhishekKumar-lu3lp Жыл бұрын
Brute force to optimised sab yaad rakhna hai ke sirf best wala
@AdityaV2024
@AdityaV2024 Жыл бұрын
Yes boss❤
@Sajal_Mallick_vlogs
@Sajal_Mallick_vlogs 10 ай бұрын
Day 40 done and dusted.... Best DSA on youtube and better than paid courses... Thank you bhaiya... #consistency
@akashkewat1219
@akashkewat1219 Жыл бұрын
Question karne mei jo maja hai wo kahi nahi 😊 thanks bhaiya❤
@akarshgoel4990
@akarshgoel4990 4 ай бұрын
48:32 Solution of trapping rain water in only one traversing: class Solution { public: int trap(vector& height) { int unit=0, start=0, end=height.size()-1, maxL=height[start], maxR=height[end]; while(start
@plutomessi21
@plutomessi21 Жыл бұрын
Bhaiya didn't deserve uber, uber deserved bhaiya ❤
@spicyedutainment1577
@spicyedutainment1577 Жыл бұрын
What a video. Now i can say that it is best dsa playlist on the youtube channel no matter you are familiar with the c++,java,python . Big shout out for Rohit Negi bhaiya . One request if possible please bring the development course. Thank You
@CoderArmy9
@CoderArmy9 Жыл бұрын
THanks
@zehrarizvi8377
@zehrarizvi8377 Жыл бұрын
Yes bhaiyya plz bring development video
@IndiLores709
@IndiLores709 11 ай бұрын
58:00 *Solution using binary search* : #include #include #include using namespace std; vector Possibility(vector& arr, int target) { int n = arr.size(); sort(arr.begin(), arr.end()); for (int i = 0; i < n - 2; i++) { for (int j = i + 1; j < n - 1; j++) { int start = j + 1, end = n - 1, mid; // Corrected the 'end' value while (start target; vector result = Possibility(v, target); if (result.empty()) { cout
@sandeepsahu2681
@sandeepsahu2681 2 ай бұрын
Timestamps 00:02 - Calculating the units of water stored between buildings. 02:08 - Storing water in between buildings 05:52 - Determining the minimum building height to store water 07:50 - Calculating support for trapping rainwater 12:02 - Calculating maximum water trapping 14:11 - Calculating trapped rainwater using a special formula 18:33 - Algorithm for calculating trapped rain water levels. 20:33 - Calculating trapped rainwater using the 3 SUM and 4 SUM method 24:31 - Solving trapping rainwater problem without using extra space 26:30 - Comparing and selecting the maximum number 30:03 - Finding maximum support for trapping rainwater 31:47 - Algorithm for trapping rainwater explained 35:13 - Algorithm explanation for trapping rainwater with 3 SUM and 4 SUM 37:07 - Finding the biggest building and calculating water storage 41:35 - Explanation of trapping rain water problem and left max estimation 43:34 - Algorithm for finding maximum building height and water trapping 47:33 - Optimizing solutions using two pointer concept 49:11 - The three sum problem is about finding three numbers in an array that add up to 13. 53:27 - Using binary search to find elements in a sorted array. 55:18 - Discussing process of finding numbers through explanations and examples. 59:15 - Converting a problem to a two sum problem 1:00:56 - Finding number combinations that add up to 20 1:05:07 - Solving the problem of triplet sum in an array. 1:07:17 - The speaker discusses finding the sum of numbers and applying conditions. 1:11:36 - Converting 4 SUM problems into 3 SUM 1:13:34 - Discussion about proof of work
@musaifbangi8705
@musaifbangi8705 2 ай бұрын
I have try solve hard problem water trapping before video. I think I won't able to solve this. But guess what I solved it. And I took 0 ms time. Time complexity O(n) and space O(1). This led my code better than the sir's code. So I created the logic in 20 - 30 mins. And the code about 15 mins. Total time 45 mins. And I used very understandable logic.
@then__i__m__rabi4939
@then__i__m__rabi4939 16 сағат бұрын
Tagda🔥🔥🔥🔥
@rahuljestha1540
@rahuljestha1540 Жыл бұрын
Bhaiya i am move from love babber to your channel bz you explain the questions so easily i am waiting for graph
@sobhansahoosubh3873
@sobhansahoosubh3873 6 ай бұрын
bhai kya explanation tha yar , 60% percent to dekhke hi clear ho gaya , ek do bar dry run khudse karluuga to pura hi clear ho jaega
@Gyanendra012
@Gyanendra012 10 ай бұрын
Baap level ka concept Chamka h bhaiya
@abhikritverma3772
@abhikritverma3772 3 ай бұрын
The best explanation i have seen for the trapping rain water .
@abhinavparashar1934
@abhinavparashar1934 7 ай бұрын
tagda 💪💪 Baap Level 💪💪
@sahilCSE999
@sahilCSE999 11 ай бұрын
Aapke jaisa bhaia 10% bhi sochne Lage to zindgi me kuch kr jayenge
@souravsanyal7154
@souravsanyal7154 11 ай бұрын
you are doing great for this community rohit bhai . may god bless you
@SKY_SACHIN
@SKY_SACHIN 2 ай бұрын
Tagda concept bhaiya
@heetpatel3037
@heetpatel3037 11 ай бұрын
Chamka bhaiya 👍🏻
@karankumar3983
@karankumar3983 Жыл бұрын
000q1 method1(m1) 4:15 m2, 36:49 m3 42:57 q1 code by m3, 47:05 q2 m1 54:00 m2 59:25 m3 its code 1:06:33 by m3 1:11:01 homework question
@heyMonikaa
@heyMonikaa 6 ай бұрын
Tagda concept ekdm chamak gya bhaiyaa ✨🤝
@sourabhgupta1466
@sourabhgupta1466 7 ай бұрын
Thagda sikkhaya bhai Maza agaya itna break down kar diya waah bhai best teacher🙏
@rishabhsharma7604
@rishabhsharma7604 10 ай бұрын
TAGDA, CHAMKA, BAAP LEVEL, ABB TOH GOOGLE PAHUCHNA APNE ASAAN KAR DIYA, Thanks a lot Bhaiya 🙏🙏
@jain_saiyam
@jain_saiyam 7 ай бұрын
IIT bhi ho rha tha na tera to
@rishabhsharma7604
@rishabhsharma7604 5 ай бұрын
@@jain_saiyam aukaat mai, baap se aise baat karte hai 😂😂
@amanassociation8745
@amanassociation8745 2 ай бұрын
Bacha hai kya tu
@rishabhsharma7604
@rishabhsharma7604 2 ай бұрын
@@amanassociation8745 aukaat mai, baap se aise baat karte hai 😂😂
@amanassociation8745
@amanassociation8745 2 ай бұрын
@@rishabhsharma7604 lgta hai pagla gya sasura 😂
@acroshubham
@acroshubham Жыл бұрын
Day: 40 HARD grinding. Walking slowly to climb up the Mt. Everest Sir. But walking consistently. You all have to believe than one day bhaiya will achieve massive success and he will not leave his students behind, he will make us also to achieve that greatness. Hats off Sir. Standing Ovation... 👏👏👏👏👏👏
@dmcreation751
@dmcreation751 Жыл бұрын
Bahut hi ache se chamak gye :)
@mratunjaisingh449
@mratunjaisingh449 5 ай бұрын
tagda bhiya💥
@riteshthings
@riteshthings Жыл бұрын
easy to understand content 🔥🔥
@a71patiladitya45
@a71patiladitya45 Жыл бұрын
Tagda ❤❤❤
@YourCodeVerse
@YourCodeVerse Жыл бұрын
chamak gaya 👍🏼🔥🔥
@yashanshhhhraj
@yashanshhhhraj Ай бұрын
Tagda, Baap level
@krishnasharma3018
@krishnasharma3018 Жыл бұрын
Thanks bhaiya.....apa itna axa se padhne k liye❤
@deepchouhan6801
@deepchouhan6801 Жыл бұрын
Everyone busy in watching animal, but me again watching rohit bhaiya 's lectures 😅😅
@sunilshekhawat5422
@sunilshekhawat5422 Жыл бұрын
Me too
@divyanshsharma673
@divyanshsharma673 11 ай бұрын
Animal is fu..k movie.
@govindraivlogs9938
@govindraivlogs9938 6 ай бұрын
Maan Gye Guru.....
@IndiLores709
@IndiLores709 11 ай бұрын
Bhaiya! for 4 sum problem, I wrote this code at my own , int Solution::minimize(const vector &A, const vector &B, const vector &C) { int n = A.size(), m = B.size(), o = C.size(); int minm = INT_MAX; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { for (int k = 0; k < o; k++) { int first = abs(A[i] - B[j]); int second = abs(B[j] - C[k]); int third = abs(C[k] - A[i]); int Q = max(max(first, second), third); // Corrected the max function if (Q < minm) { minm = Q; } } } } return minm; } But this is not optimal solution at all. We are not taught pointers yet.
@mahipatel8096
@mahipatel8096 Жыл бұрын
Baap level bhai ❤🙏🏻
@interestingduniya555
@interestingduniya555 4 ай бұрын
Love u bhaiya ❤
@PankajSaindane-k6r
@PankajSaindane-k6r 7 күн бұрын
Baap concept
@rajibdas5574
@rajibdas5574 5 ай бұрын
One of the lucid explanation.
@nitinpal880
@nitinpal880 Жыл бұрын
tagda concept sikha rhe ho bhaiyya
@tanmayjivnani865
@tanmayjivnani865 27 күн бұрын
Baap Level 🔥🤌🏻
@gi9abite
@gi9abite Жыл бұрын
Baap level concept tha bhaiya🤩
@Vivekkumarmishra01
@Vivekkumarmishra01 Жыл бұрын
tagda concept bhaiya
@atifmalik8012
@atifmalik8012 3 ай бұрын
35:30 //O(1) space complexity class Solution { public: int trap(vector& height) { int Maxi=0,n = height.size(); for(int i = 0;iheight[Maxi]) Maxi = i; } int leftMax = 0,rightMax = 0,temp,ans=0; for(int i = 0;i0) ans+=temp; leftMax = max(leftMax,height[i]); } for(int i = n-1;i>Maxi;i--) { temp = rightMax-height[i]; if(temp>0) ans+=temp; rightMax = max(rightMax,height[i]); } return ans; } };
@-AjayChauhan
@-AjayChauhan Жыл бұрын
thanks bhaiya 😀😀
@vijaybhadadebillionaire8944
@vijaybhadadebillionaire8944 Жыл бұрын
khatarnak problem solution
@prabhatkumar08
@prabhatkumar08 28 күн бұрын
Thanks nicely explained.
@raghavsharma1484
@raghavsharma1484 4 ай бұрын
tagda baap level😎
@shubhamkumarjha9192
@shubhamkumarjha9192 Жыл бұрын
Ab dheere dheere BAAP Level kee aur badhte hue...😂❤❤
@IGNITE1729
@IGNITE1729 12 күн бұрын
BAAP LEVEL
@dataScience7845
@dataScience7845 Жыл бұрын
Tagda :):):)
@sharwan0143
@sharwan0143 8 ай бұрын
next level bhaiya
@tarunaggarwal8065
@tarunaggarwal8065 7 ай бұрын
Tagda Concept seekha 🥰
@DesiMrBean7
@DesiMrBean7 Жыл бұрын
BAAP bolte 🔥🔥
@Any_289
@Any_289 Жыл бұрын
Maja a gaya bhaiya ❤
@Jawed45621
@Jawed45621 4 ай бұрын
vai best
@farooqueansari5406
@farooqueansari5406 9 ай бұрын
Superb explanation, will never forget now 😅❤
@Rohangamin517
@Rohangamin517 Жыл бұрын
Baap level😊😊
@AyushVerma-wu3nn
@AyushVerma-wu3nn 10 ай бұрын
Respect Earned!!
@_hulk748
@_hulk748 Жыл бұрын
great explanation sir🙏🙏🙇‍♂🙇‍♂✨✨💖
@syedmustafaquadri4441
@syedmustafaquadri4441 Жыл бұрын
Chamka Bhai Chamka
@tripurarisen4362
@tripurarisen4362 9 ай бұрын
Tagra❤❤
@avanishyadav5490
@avanishyadav5490 Жыл бұрын
Superb bhaiya🙏🙏
@Sangi-sj2dy
@Sangi-sj2dy 7 ай бұрын
Simply Awesome
@RDX-369
@RDX-369 Жыл бұрын
Good afternoon beji ❤
@Roronoa_70RO
@Roronoa_70RO 4 ай бұрын
chamak gya
@saitanush9453
@saitanush9453 8 ай бұрын
Tq bhaiya for today😄😄
@samander2934
@samander2934 Жыл бұрын
Tagda
@Updatedknowledge9
@Updatedknowledge9 Жыл бұрын
Awesome 😊 lecture
@joydipsen3057
@joydipsen3057 5 ай бұрын
When I see the problem first, I do it in n time complexity and 1 space complexity. Here's the program // Trapping rain water(n time complexity & 1 space complexity) #include using namespace std; int main() { int arr[100],n; cin>>n; for(int i=0;i>arr[i]; } int highest=0; for(int k=1;karr[highest]) highest=k; } //break into two part;left side and right side of highest piler int large=0,small=1,store=0; for(int j=0;jarr[small]) { store=store+(arr[large]-arr[small]); small++; } else if(arr[large]highest+1;j--) { if(arr[large]>arr[small]) { store=store+(arr[large]-arr[small]); small--; } else if(arr[large]
@Code_with_Tiwarijii
@Code_with_Tiwarijii Жыл бұрын
1:06:24 chamak gya bhaiya .
@NoorulAbdeenSiddiqui
@NoorulAbdeenSiddiqui 7 ай бұрын
u are the best
@Gyanendra012
@Gyanendra012 10 ай бұрын
Q. trapping rain water class Solution { public: int trap(vector& height) { int n=height.size(),maxWater=0,minHeight=0; vectorpremax(n); premax[0]=height[0]; vectorsufmax(n); sufmax[n-1]=height[n-1]; for(int i=1;i=0;i--){ sufmax[i]=max(sufmax[i+1],height[i]); } for(int i=1;iheight[i]){ maxWater+=minHeight-height[i]; } } return maxWater; } };
@coding24335
@coding24335 2 ай бұрын
❤❤❤
@ankitpal8380
@ankitpal8380 Жыл бұрын
Chamak gaya hai concept bhaiya
@shubhamkumarjha9192
@shubhamkumarjha9192 Жыл бұрын
Good morning bhaiya.❤️❤️
@shivammanitripathi4226
@shivammanitripathi4226 Жыл бұрын
thank you for providing best content
@AbhayKumar-or7qt
@AbhayKumar-or7qt 3 ай бұрын
thank you sir
@newglobal2056
@newglobal2056 Жыл бұрын
First view ❤❤❤
@atharva_g_vlogs
@atharva_g_vlogs 4 ай бұрын
BaapLevel TAGDA CONCEPT
@dviolet07
@dviolet07 5 ай бұрын
happy teachers day bhaiya
@anupammishra6514
@anupammishra6514 Жыл бұрын
@joydeep-halder
@joydeep-halder Жыл бұрын
Good Morning bhaiya ❤❤
@muskn7239
@muskn7239 4 ай бұрын
baap level chamka bhaiyaa
@nikhil_yaduvanshi01
@nikhil_yaduvanshi01 Жыл бұрын
🔥🔥
@AMITKUMAR-ds4hp
@AMITKUMAR-ds4hp Жыл бұрын
Good morning boss ❤❤
@CSEBivekKumarSahNirala
@CSEBivekKumarSahNirala Жыл бұрын
Chamak gaya bhaiya
@MohammedHasmi577
@MohammedHasmi577 9 ай бұрын
Nice bro ❤
@TheSilentObserver30
@TheSilentObserver30 Жыл бұрын
Day 40/180 . Moving forward with confidence just because of you ♥♥.Thank you
@deepaktudu025
@deepaktudu025 Жыл бұрын
Baap level concept
@arpitkhandelwal8280
@arpitkhandelwal8280 6 ай бұрын
Day 40 done and dusted....chamka diya bhaiya
@souravsanyal7154
@souravsanyal7154 11 ай бұрын
can we use two pointer ?? by using switch case?
@coding24335
@coding24335 2 ай бұрын
Pro coder
@iamalcohishan106
@iamalcohishan106 Жыл бұрын
❤❤❤❤
@CHAUDHARY_PRAYAS
@CHAUDHARY_PRAYAS Жыл бұрын
#40 out of 180 Good morning bhaiya
@sagestudy
@sagestudy Жыл бұрын
Concept++
@dayashankarlakhotia4943
@dayashankarlakhotia4943 Жыл бұрын
class Solution { public int trap(int []height){ if(height. length ==0) return 0; int ans=0,l=0,r=height.length-1; int maxL=height [l]; int maxR=height [r]; while(l
@-BCS-VarshaVaishnav
@-BCS-VarshaVaishnav Жыл бұрын
Day 40/180 done thanku bhaiya🙃
@shubhamtiwari9817
@shubhamtiwari9817 Жыл бұрын
good morning bheji ❤
@PradeepKumar-bc1ez
@PradeepKumar-bc1ez Жыл бұрын
Thankyou bhaiya
@salimjadhaw1650
@salimjadhaw1650 8 ай бұрын
thank u so much bhaiyya
Lecture 31: Introduction To 2D Arrays in C++
1:25:01
Coder Army
Рет қаралды 43 М.
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
Trapping Rain Water - Google Interview Question - Leetcode 42
23:21
4 Sum | Brute - Better - Optimal with Codes
28:47
take U forward
Рет қаралды 212 М.
Learn Coding & Get a Job (in 2025) 🔥
16:54
CodeWithHarry
Рет қаралды 1 МЛН
L8. Trapping Rainwater | 2 Approaches | Stack and Queue Playlist
28:58
But what is a neural network? | Deep learning chapter 1
18:40
3Blue1Brown
Рет қаралды 18 МЛН