Lecture 80: Longest Common Prefix Problem || Tries || C++ Placement Series

  Рет қаралды 117,616

CodeHelp - by Babbar

CodeHelp - by Babbar

Күн бұрын

In this Video, we are going to learn about Trie in C++ and Questions
There is a lot to learn, Keep in mind “ Mnn bhot karega k chor yrr apne se nahi hoga ya maza nahi aara, Just ask 1 question “ Why I started ? “
[For 20% Discount ] Visit Coding Ninjas: bit.ly/3cfdKTe
Discord Server Link: / discord
Course Flow: whimsical.com/...
Notes Link: drive.google.c...
Slides Link: drive.google.c...
Code Links: github.com/lov...
Questions Links:
- Longest Common Prefix: www.codingninj...
Do provide you feedback in the comments, we are going to make it best collectively.
Connect with me here:
Instagram: / lovebabbar1
Twitter: / lovebabbar3
Telegram Group Link: Love Babbar CODE HELP
telegram.me/lo...
My Editor: www.instagram....
Intro Sequence: We have bought all the required Licenses of the Audio, Video & Animation used.
#DSABusted #LoveBabbar

Пікірлер: 187
@md.ualiurrahmanrahat2400
@md.ualiurrahmanrahat2400 2 жыл бұрын
finished your 60th video today. Came here to show my support. Please don't be disappointed as the view are declining. Once we finished the other videos, we will come here too. This is the only comprehensive DSA PlayList available on KZbin. This is much much better than hundreds of paid courses.
@vaidanshkukreja8970
@vaidanshkukreja8970 2 жыл бұрын
Is it just me or with everyone that feels babbar bhaiya is exhausted but still recording the video Bhaiya please take proper rest and then start the course again. We need your full power !!!
@Code0x64
@Code0x64 Жыл бұрын
Really Enjoyed this. However, one small check to be done for corner testcases: //insert all strings into Trie for (int i = 0; i < strs.size(); i++) { if(strs[i].empty()) // missing check to return in cases where the string is empty return ""; t->insertWord(strs[i]); }
@human75788
@human75788 2 жыл бұрын
❤💯 already solved trie construction in the morning today of leetcode both recursive and iterative approaches, both were right just by understanding the logic from you... so simple and easily understandable
@gb9374
@gb9374 2 жыл бұрын
bhaiya big fan 1 more approach :- sorting karke first and last string compare karenge to ans mil jayega string longestCommonPrefix(vector &arr, int n) { // Write your code here if(n==0)return ""; if(n==1)return arr[0]; sort(arr.begin(),arr.end()); string ans=""; string a=arr[0]; string b=arr[n-1]; for(int i=0;i
@aaryannaugaraiya1118
@aaryannaugaraiya1118 2 жыл бұрын
Bhaiya, maza aarha h... Coding ab ho rhi h.. Leetcode ke questions bn rhe h.. Happy😁 Credit goes to you ☺
@inspiringzone12
@inspiringzone12 2 жыл бұрын
Attandance ++ Consistency++ Thank you ++
@prashantbirajdar9271
@prashantbirajdar9271 2 жыл бұрын
wahh sirr another an exciting session ...wow.....but the second Trie mehtod approach giving TLE at submission time.... but first approach is optimal code solution for this problem...thanks sirrr...consistancy , respect , hardwork , dedication , passion ++++++
@meme_eternity
@meme_eternity 2 жыл бұрын
yes it is giving TLE
@042_dikshasakhare6
@042_dikshasakhare6 Жыл бұрын
yayy its showing tle
@do_not_want_to_show
@do_not_want_to_show 2 жыл бұрын
Bhai saab, JOB + Consistency == Faadu 🔥🔥🔥.
@akashkumarmaurya2319
@akashkumarmaurya2319 2 жыл бұрын
maja aa rha hai .. previous day maine leet code , visual code , gfg se trise k question kara ,easy and loving this lecture for me...tq bhaiya for this...
@varshadagar2140
@varshadagar2140 2 жыл бұрын
loving it consistency++++++++
@krishnaradhey2814
@krishnaradhey2814 2 жыл бұрын
JAI SIYA RAM BHAI you are doing tremendous work
@CODEWK7
@CODEWK7 2 жыл бұрын
I am in recursion .... we all are with you
@Bad_Avadh
@Bad_Avadh 2 жыл бұрын
int n=strs.size(); string ans=""; sort(strs.begin(),strs.end()); string s1=strs[0]; string s2=strs[n-1]; for(int i=0;i
@MohammadAmmar-jr3sp
@MohammadAmmar-jr3sp 8 күн бұрын
We can clearly see how much effort you are putting to provide us the quality content. recording the video half asleep🙂🙂🙂 dedication level is ++ GURU JI ++
@mr.himanshu4299
@mr.himanshu4299 2 жыл бұрын
consistency vaps le aae ho bht ache bht ache
@NinjaCoders
@NinjaCoders Жыл бұрын
Your teaching is really Excellent, very simple to understand
@fazerugbrug439
@fazerugbrug439 2 жыл бұрын
aaag laga diya bhaiyaa
@amishapandey6875
@amishapandey6875 Жыл бұрын
Completed 80lectures!! 60 more to go!
@shrutijaiswal871
@shrutijaiswal871 2 жыл бұрын
Jaldi complete krrao bhaiya , mid March ka promise kiya tha apne , abb toh mid Aprila aaagya !!
@utkarshsingh1457
@utkarshsingh1457 2 жыл бұрын
Enjoyed a lot... Thanks for making such a quality content ❤️❤️
@RavinderSingh-yo7dx
@RavinderSingh-yo7dx 2 жыл бұрын
I am really really impressed with the way you teach. Thanks much. I have a question and I hope you wont mind revealing it. Actually I am really very curious to know that how long or how much time do you study in a day?
@RajKumar-vq1nm
@RajKumar-vq1nm 2 жыл бұрын
Back to form..U have given enough upcoming students..❤️
@anuragpandey8165
@anuragpandey8165 2 жыл бұрын
Again out of form ig
@AnonymousCoder7
@AnonymousCoder7 2 жыл бұрын
Just watched video review of your course by @desi coder . My comment there is "Best DSA course on YT🏅🏅🏅" Really Love bhai .. Thanks a lot for putting such an efforts... Don't worry about People getting impatient about the completion of this course. I know this will be completed. Iss level ka content wo b free me ... Hatts offff... Traits of an Army attitude🏅🏅🏅 Love, Abhishek Sharma Punjab
@bhawargujral3574
@bhawargujral3574 2 жыл бұрын
I am from punjab as well.. Which district by the way?
@AnonymousCoder7
@AnonymousCoder7 2 жыл бұрын
@@bhawargujral3574 Hoshiarpur bro ... 🤝
@kunaljain1168
@kunaljain1168 2 жыл бұрын
Make playlist for and Trie.
@vishalgarna4580
@vishalgarna4580 Жыл бұрын
Osm content ❤❤❤😊😊
@ajvlogs1501
@ajvlogs1501 2 жыл бұрын
can someone please tell me how much syllabus of DSA is reamining and approximately how much videos will it take to complete,BTW execellent work bhaiya we can see all your efforts❤
@someshsangwan5302
@someshsangwan5302 2 жыл бұрын
Dont worry bro i think there will be little topics like - DP and graph mostly
@Abhishek-ji6qj
@Abhishek-ji6qj Жыл бұрын
#Python:- x = ["flower", "flosing", "flowing"] prefix = "" for i in range(len(x[0])): flag = 0 temp = x[0][i] for j in range(1, len(x)): if not x[j][i] == temp: flag = 0 break else: flag = 1 if flag ==1: prefix+=temp else: pass print(prefix)
@alokranjan3185
@alokranjan3185 2 жыл бұрын
Thanks for this awesome series sir
@ravivishvas3676
@ravivishvas3676 2 жыл бұрын
next level efforts 🔥🔥
@RavindraSingh-zg9eq
@RavindraSingh-zg9eq 9 ай бұрын
no one can beat u bhai in teaching and knowledge
@excelexpertclasses6776
@excelexpertclasses6776 10 ай бұрын
completed this lecture babbar ji still continuing to complete your whole data structure series !!!!!
@bhawargujral3574
@bhawargujral3574 2 жыл бұрын
Consistency 😍 thank you for the course👏
@RohitKumar-oo8lo
@RohitKumar-oo8lo 2 жыл бұрын
Bhaiya lage raho..hum thoda video peeche hai...aap please Videos banate jao..hum saath me hai aapke ! 🔥
@shantanu8880
@shantanu8880 11 ай бұрын
My logic was: We can insert one string to the trie, then for rest of the strings we need to check the common prefix, but here must be a catch, [coding, code, codingninjas] -> here ans should be cod, so we need to store the min(ans, tempStr).
@heybiplabb
@heybiplabb 2 жыл бұрын
Present bhaiya ✋
@user-ic7mg6lz2k
@user-ic7mg6lz2k 2 жыл бұрын
congratulations you have been selected amongst our shortlisted winners ✅ A direct message 👆
@BornHubisLive
@BornHubisLive 2 жыл бұрын
Thanks A lot BHaiya.......RESPECT++;
@lokendrasingh9780
@lokendrasingh9780 Жыл бұрын
This series is helping alot❤❤👍👍😊😊
@kshitizmayank7208
@kshitizmayank7208 8 ай бұрын
hello bhaiya ik this is too late to ask but looks like you were unwell/sick while recording this lecture ,is it true? thanks for the efforts you put for us
@rachit_joshi
@rachit_joshi 3 ай бұрын
Thank You So Much BHRATA SHREE !!!!!!!
@yashasvic2429
@yashasvic2429 Жыл бұрын
Thanks Bhai, these tutorials really helped me all these times.
@gitanjalikumari9262
@gitanjalikumari9262 2 жыл бұрын
great explanation...thank you so much for making our path easy
@lapade
@lapade Жыл бұрын
Hanji 🎉
@BhaiRayyanKiDuniya
@BhaiRayyanKiDuniya 2 жыл бұрын
kk luv u bro good job MAKE Your FAMILY HAPPY AND SATISFIED WITH WHAT YOU DO
@jericodcosta2049
@jericodcosta2049 2 жыл бұрын
Attandance marked now solving stack questions Josh is high
@anuragpandey8165
@anuragpandey8165 2 жыл бұрын
Bhai aur kitna late karoge yaarrr..... I am following this course from Lecture 1 and here I am after completing all the previous videos...... Please maintain some consistency..... at least 1 vid in 2 days.
@ashutosh61290
@ashutosh61290 2 жыл бұрын
bro unka job bhi h, thoda unke bare me bhi socho.... waise hi clear dikh rha h ki wo kitne thke hue h.. phir bhi kr rhe h.
@vashishthsharma4411
@vashishthsharma4411 2 жыл бұрын
thank you bhaiya 😇😇🙏
@mihirvargante66
@mihirvargante66 2 жыл бұрын
thanx:)
@ayushgoyal8972
@ayushgoyal8972 9 ай бұрын
we can use linked list as well
@jaydwarkadhish959
@jaydwarkadhish959 2 жыл бұрын
Sir amazing video
@kumarpawansahh
@kumarpawansahh 2 жыл бұрын
Krenge bhaiya ....aap ho toh mumkin hai
@govindnair3135
@govindnair3135 2 жыл бұрын
Love you bhaiyya ❤️😘....thanks a lot for this.....please don't change bhaiyya.....love youuuuu
@AnkitRaj-pp6ph
@AnkitRaj-pp6ph 2 жыл бұрын
Will this course continue
@smanivesh
@smanivesh 2 жыл бұрын
bhaiya.. what will be the Longest Common Prefix for ["flowering" , "flringow" , "flringight"] ans..fl or ring?? please resolve this confusion!!
@Tradvesting89
@Tradvesting89 2 жыл бұрын
it should be ring , as it is "longest common"
@hiddenmaster1724
@hiddenmaster1724 2 жыл бұрын
The correct ans is fl Reason is- question is about the longest common prefix and not longest common substring
@Tradvesting89
@Tradvesting89 2 жыл бұрын
@@hiddenmaster1724 why ring is not prefix ?
@hiddenmaster1724
@hiddenmaster1724 2 жыл бұрын
@@Tradvesting89 Prefix occurs at the beginning of root and not in between. "Ring" is a sub-part/sub-string.
@Tradvesting89
@Tradvesting89 2 жыл бұрын
@@hiddenmaster1724 flringow and flringight has ring in first part only
@sukhjitsingh959
@sukhjitsingh959 2 жыл бұрын
I trust you Babar thanks 👍
@arpitrajput6424
@arpitrajput6424 2 жыл бұрын
Having problem to solve more problem anyone suggest me where i can ask my doubt ,any whatsapp group or discard server
@anuragraut5101
@anuragraut5101 2 жыл бұрын
Attendance++
@user-ic7mg6lz2k
@user-ic7mg6lz2k 2 жыл бұрын
congratulations you have been selected amongst our shortlisted winners ✅ A direct message 👆
@focus.placement5589
@focus.placement5589 2 жыл бұрын
thanks bhaiya crystal clear hai
@sanskrutishahu517
@sanskrutishahu517 2 жыл бұрын
Video late aayegi chalega btt health comes first take proper rest and care bhaiya.
@teenageworrior1634
@teenageworrior1634 2 жыл бұрын
💯🙏Bhaiya lecture 17,18,19 .. etc ke handwritten notes bhi daliye plz🙏❤
@codingindisguise
@codingindisguise Жыл бұрын
Easy and Smooth!!💯
@user-tx3vv4nx8h
@user-tx3vv4nx8h Жыл бұрын
Hello Love Babbar sir, Thank you for sharing great knowledge. In this lecture you taught us one brute force solution with O(n*m) time complexity, I found one exception for shared solution, That code is not compatible with test case = [ "ab" , "a" ]. And I found quite better solution for that, which allows almost all test cases. If you allow me I want to contribute that updated code. Thank you.
@anupamdhauria1704
@anupamdhauria1704 Жыл бұрын
can you share your solution here?
@KratosProton
@KratosProton 2 жыл бұрын
Great explaination
@sumitrawat9526
@sumitrawat9526 2 жыл бұрын
Bhaiya we are with you..
@sukhpreetsingh5200
@sukhpreetsingh5200 Жыл бұрын
are mjja aa gya
@satyanarayanareddy8817
@satyanarayanareddy8817 2 жыл бұрын
hi sir i am from andrapradesh (AP)i dont know hindi well i am seeing your videos using subtitles but from past videos onwards subtitles are turned off..can you please turn on for nextvideo on wards
@jessicasinha9009
@jessicasinha9009 2 жыл бұрын
Thank u bhaiya for your efforts
@laksheybanga8106
@laksheybanga8106 2 жыл бұрын
Bhaiyaaa tussi great ho 💓💓
@sajaljain712
@sajaljain712 2 ай бұрын
LEET CODE 14: LONGEST COMMON PREFIX (SOLUTION CODE) class TrieNode { public: char data; TrieNode* children[26]; bool isTerminal; int childCount; TrieNode(char ch){ data = ch; for(int i=0;iisTerminal = true; return; } int index = word[0] - 'a'; TrieNode* child; if(root->children[index] != NULL){ child = root->children[index]; } else{ child = new TrieNode(word[0]); root->childCount++; root->children[index] = child; } insertUtil(child, word.substr(1)); } void insertWord(string word){ insertUtil(root,word); } void lcp(string str, string& ans){ for(int i=0;ichildCount == 1){ ans.push_back(ch); int index = ch-'a'; root=root->children[index]; } else break; if(root->isTerminal) break; } } }; class Solution { public: string longestCommonPrefix(vector& strs) { Trie* t = new Trie(); for(auto i:strs){ if(i == "") return ""; t->insertWord(i); } string first = strs[0]; string ans = ""; t->lcp(first,ans); return ans; } }; // ❤
@jenishdabhi7480
@jenishdabhi7480 2 жыл бұрын
hashmaps ke question karao
@ArpitKumar-yo6up
@ArpitKumar-yo6up 2 жыл бұрын
Thanku for making great videos bhaiya
@vipulchaudhary_js
@vipulchaudhary_js Жыл бұрын
Code here : leetcode.com/problems/longest-common-prefix/discuss/2659408/cpp-trie-love-babbar-approach
@TechUprise-by-Jyoti
@TechUprise-by-Jyoti 2 жыл бұрын
Thank you bhaiya😄consistency OP🥰
@user-ic7mg6lz2k
@user-ic7mg6lz2k 2 жыл бұрын
congratulations you have been selected amongst our shortlisted winners ✅ A direct message 👆
@shivkumar-og4ow
@shivkumar-og4ow 2 жыл бұрын
Thanks alot bhaiya.. consistency++
@govindsuryavanshi6653
@govindsuryavanshi6653 Жыл бұрын
First I have completed all DSA series and now conclude this is Greatest ever DSA series to exists on youtube or paid courses. Your contribution will be remembered. You're God of DSA for us🙇‍♂ Thanks you.
@Learnprogramming-q7f
@Learnprogramming-q7f 7 ай бұрын
Thank you Bhaiya
@avishkarpatil5871
@avishkarpatil5871 6 ай бұрын
9:09 // - Missing Case Make sure that -> i >= arr[j].size() not i > arr[j].size() if(i >= arr[j].size() || arr[j][i] != arr[0][i]){ check = false; break; } // Complete Code string longestCommonPrefix(vector &arr, int n) { int m = arr[0].size(); string ans = ""; for(int i = 0; i < m; i++){ bool check = true; for(int j = 1; j < n; j++){ if(i >= arr[j].size() || arr[j][i] != arr[0][i]){ check = false; break; } } if(check) ans.push_back(arr[0][i]); else break; } return ans; }
@studywithme66
@studywithme66 2 жыл бұрын
Thanks for your affort
@BhaiRayyanKiDuniya
@BhaiRayyanKiDuniya 2 жыл бұрын
Hope to greet you someday after getting placed
@nishudwivedi3478
@nishudwivedi3478 2 жыл бұрын
Bhaiya os ki trh dbms Or cn ka series bhi start kariye please bhaiya humble request... 🙏🙏🙏
@nishudwivedi3478
@nishudwivedi3478 2 жыл бұрын
Dsa course kb complete hoga...?
@memorybyshubhammanitripath4368
@memorybyshubhammanitripath4368 2 жыл бұрын
Maja aa gya bhaiya 😍😍😍 Finally aap ko catch kar liya course pe Ab aap ke sath daily daily wale video dekhi ga Aur ab hoga practice starting se #reached Lekin bhaiya code link update kar do 😁 Maja bahut aa raha Mera final sem chal raha lekin phir bhi continuous hu aap ke karan Kal mera paper hai 😂🤣😁🤣 You are best 😍😍😍
@NikhilSharma-qc1ez
@NikhilSharma-qc1ez 2 жыл бұрын
Bhaiya lecture 81 kab ayega
@deepakgarg2547
@deepakgarg2547 2 жыл бұрын
Pls tell@Love babbar total kitni video aaygi DSA course mein pls ek idea bta do🙏🙏🙏🙏🙏🙏
@tejashmaurya2149
@tejashmaurya2149 Жыл бұрын
while(1) { love Babber; }
@studywithme66
@studywithme66 2 жыл бұрын
Yes sir hum kar rahe hai abhi se
@iteself_me
@iteself_me Жыл бұрын
kadak
@akankshapandey8316
@akankshapandey8316 2 жыл бұрын
Thanku Sir🙏
@randomguy7246
@randomguy7246 11 ай бұрын
Trie just makes the code unncessasarily lenghty and hard. is trie necessary to learn as I am not liking it much
@vishichaurasiya4427
@vishichaurasiya4427 Жыл бұрын
Mza++
@sukhjitsingh959
@sukhjitsingh959 2 жыл бұрын
Can I get loan zero interest to buy new laptop ...need it badly now ....
@BhaiRayyanKiDuniya
@BhaiRayyanKiDuniya 2 жыл бұрын
keep it up
@iteself_me
@iteself_me Жыл бұрын
160 ✅completed 👍Liked 2:30
@prathmeshghate6404
@prathmeshghate6404 2 жыл бұрын
bhaya video dalo jaldi cover karliya hai saara
@vivekjaiswal4391
@vivekjaiswal4391 Жыл бұрын
Os is of bohot confusion hua isse
@Ankitnsk178
@Ankitnsk178 3 ай бұрын
Understood++
@shresthkaushik6636
@shresthkaushik6636 Жыл бұрын
thx sir 🙏
@vivan1852
@vivan1852 2 жыл бұрын
Attendance done ,
@abhisheksameer1842
@abhisheksameer1842 2 жыл бұрын
maja aa rha
@prashantshukla6870
@prashantshukla6870 2 жыл бұрын
Mza aagya bhaiaya
@user-ic7mg6lz2k
@user-ic7mg6lz2k 2 жыл бұрын
congratulations you have been selected amongst our shortlisted winners ✅ A direct message 👆
Lecture 79: Trie & its Implementation || C++ Placement Series
48:20
CodeHelp - by Babbar
Рет қаралды 137 М.
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 5 МЛН
ПРИКОЛЫ НАД БРАТОМ #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
АЗАРТНИК 4 |СЕЗОН 2 Серия
31:45
Inter Production
Рет қаралды 1 МЛН
How I Failed the Google Coding Interview (and lessons I learned)
14:24
L3. Longest Word With All Prefixes | Complete String | Trie
25:31
take U forward
Рет қаралды 74 М.
Solve Any Pattern Question With This Trick!
57:20
Kunal Kushwaha
Рет қаралды 2,4 МЛН
How Would I Learn To Code (If I Was To Start Over) 🔥🔥
9:28
CodeWithHarry
Рет қаралды 2 МЛН
DP 27. Longest Common Substring | DP on Strings 🔥
14:02
take U forward
Рет қаралды 214 М.
LeetCode 14. Longest Common Prefix Solution Explained - Java
6:33
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 5 МЛН