L2. Implement Trie-2 | INSERT | countWordsEqualTo() | countWordsStartingWith() | C++ | Java

  Рет қаралды 79,074

take U forward

take U forward

2 жыл бұрын

Check our Website:
In case you are thinking to buy courses, please check below:
Link to get 20% additional Discount at Coding Ninjas: bit.ly/3wE5aHx
Code "takeuforward" for 15% off at GFG: practice.geeksforgeeks.org/co...
Code "takeuforward" for 20% off on sys-design: get.interviewready.io?_aff=takeuforward
Crypto, I use the Wazirx app: wazirx.com/invite/xexnpc4u
Take 750 rs free Amazon Stock from me: indmoney.onelink.me/RmHC/idje...
Earn 100 rs by making a Grow Account for investing: app.groww.in/v3cO/8hu879t0
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
---------------------------------------------------------------------------------------------------------------------------------------------------- C++/Java Codes - takeuforward.org/data-structu...
Pre-requisite: First Video of the Playlist: • L1. Implement TRIE | I...
In this video, we discuss the Insert, search and start with the functionality of TRIE Data Structure and its usage!
Please share this channel as much as you can. Also, it's an earnest request to drop a comment "understood" if you are watching this video, so that I get to know you understood from this video.
SDE-Sheet/Linkedin/Telegram/Instagram: linktr.ee/takeUforward
-------------------------------------------------------------------------------------------------------------
Problem Link: bit.ly/3qwT4OL

Пікірлер: 215
@takeUforward
@takeUforward 2 жыл бұрын
Just a small request, please do comment “understood” if you understand by watching this video. Helps me a lot mentally. Hardly will take 2 seconds!! Lets start this trend on TUF for every video you watch ☺️
@anujtyagi4047
@anujtyagi4047 2 жыл бұрын
FAILED TESTCASE ------- if a word doesn't exist but some starting letter exists for example "anuj " does not exist but 'an' does. in this case, when the erase function works, it returns, but decrements prefixes that should not be decremented.
@ankursharma6084
@ankursharma6084 2 жыл бұрын
@@anujtyagi4047 yes we just need to check if the word actually exists in the trie.
@jaisamtani303
@jaisamtani303 2 жыл бұрын
@@anujtyagi4047, Instead of having a endsWith property for each trieNode, we can have a static Map wordCounts which has word as key & its count as value. Whenever you have completed a word, just increment its count in the above map instead of incrementing endsWith. Eg: Map = {"apple" : 2, "apps" :2} Advantages of Map: Now for 3rd functionality i.e countWordsEqualTo(), we don't have to traverse Trie, instead we can simply check word in Map and return its count thus reducing TC from O(N) to O(1). For 5th functionality i.e erase() function we can just check if word exist in map, if yes then only we will traverse trie and reduce prefixCount for each character. If not then we simply return and the issue pointed by you is resolved. Thus Map storing is much better option than endsWith!
@jhawkzzz
@jhawkzzz 8 ай бұрын
@@ankursharma6084 To do this with O(n) space/time, iterate like you're going to erase the word, but push each node onto a stack. If you successfully reach the last node for the letter (and its word count is > 0, meaning you didnt happen on a prefix that matches the word to be erased), decrement that, then iterate the stack and decrement each node's prefix value. The corner case I'm referring to is, say the word "apples" is in the trie, and you call delete on "apple". You actually don't want to allow that, so you need to ensure the 'e' has an 'endingWord' count > 0.
@manshishreya1282
@manshishreya1282 7 ай бұрын
@takeUforward don't you think there is mistake in erase function bcoz you are decreasing count prefix but if in that path only that word is going till end then we should erase the node also ( link[ch-'a']=NULL) whenever we will find count prefix ==0 after decreasing it remove funtiion in Node* should be like this bool remove(char ch){ link[ch-'a']->cnt--; if(link[ch-'a']->cnt==0){ link[ch-'a']=NULL; return true; } return false; }
@domod481
@domod481 2 жыл бұрын
See the enthusiasm !! See the energy of Striver while teaching!! Aur Kunaal bolta hai ki padhaane nahi ata 🙂.. I have learnt almost all the concepts of DSA from your free videos.. best source best channel.. favourite as always 💫
@Ayush37262
@Ayush37262 16 сағат бұрын
Kunal toh bkl hai
@user-lt2ie8ys3n
@user-lt2ie8ys3n 6 күн бұрын
After struggling in the previous question for hours and watching the video three times, I wrote the code myself for this question after understanding the approach behind it. Thanks Striver !!
@sayandey2492
@sayandey2492 9 ай бұрын
OMG!!!!...Just one day ago, I just knew the term "Trie" and today, after seeing Lecture 1 of this series, I am able to solve this problem just after listening about the approach for the insert operation only. You are real boss man...Hats off !
@nagatanujabathena6319
@nagatanujabathena6319 2 жыл бұрын
I really like the code quality of the code you write. This is the best resource in my opinion! Thanks a lot!
@amishasahu1586
@amishasahu1586 2 жыл бұрын
"UNDERSTOOD". Your enthusiasm in teaching boost the learners. Thanks a lot. 🤗
@abinashpradhan9047
@abinashpradhan9047 2 жыл бұрын
You are amazing bro the style you approach the problem and your explanation is just ohh there is no word to say keep doing this effort Really really greatful to you
@dailydestress6189
@dailydestress6189 Жыл бұрын
All test cases passed on my first submission. Thanks for e so explaining so well.
@TheElevatedGuy
@TheElevatedGuy 2 жыл бұрын
Understood! Thanks you Striver! It was really helpful!
@shindepranjal5782
@shindepranjal5782 2 жыл бұрын
I did it myself without looking at solution. Thanks Striver
@sohamsen7892
@sohamsen7892 2 жыл бұрын
Understood the explanation. Haven't watched the coding part as yet since I want to try it on my own.
@udaytewary3809
@udaytewary3809 Жыл бұрын
Understood bhaiya you are just awesome we are very lucky to have you 😊
@sukhpreetsingh5200
@sukhpreetsingh5200 Жыл бұрын
Understood just awesome thanks a lot for this great content
@jaisamtani303
@jaisamtani303 2 жыл бұрын
Instead of having a endsWith property for each trieNode, we can have a static Map wordCounts which has word as key & its count as value. Whenever you have completed a word, just increment its count in the above map instead of incrementing endsWith. Eg: Map = {"apple" : 2, "apps" :2} Advantages of Map: Now for 3rd functionality i.e countWordsEqualTo(), we don't have to traverse Trie, instead we can simply check word in Map and return its count thus reducing TC from O(N) to O(1). For 5th functionality i.e erase() function we can just check if word exist in map, if yes then only we will traverse trie and reduce prefixCount for each character. If not then we simply return and the issue pointed by you is resolved. Thus Map storing is much better option than endsWith!
@adityajain8535
@adityajain8535 Жыл бұрын
ache questions mein MLE aayega
@jaisamtani303
@jaisamtani303 Жыл бұрын
@ayushnegi4432 raja C++ ki duniya se nikal bahar. Java me ordered/unordered kuch nai hota, simple Map hota hai jis ka average complexity O(1) hai, baki khudse key ka structure wrong karega toh O(logn) toh hoga hi. Raja agar Map use kar rha hai toh space toh badhegi na. Space complexity badhate hai taki Time Complexity kam ho Map use karna galat nai hai, question kw constraint bht high ho toh extra space use karna hi padta hai 8-9 jagah spam nai kiya, jo code daal rhe the unko mera solution bataya taki discuss kare jaise tu kar rha hai discuss raja
@nagendramanthena2458
@nagendramanthena2458 Жыл бұрын
wow best teaching and clean code superb brother
@aadharjain313
@aadharjain313 6 күн бұрын
In the erase function , it will be better to first iterate once over the word, to check if it exists or not. We can possibly take a flag to check that. If exists then go again once more to reduce counts. This way code will be more robust to user mistakes and we don't need to assume that word asked to be erased always exists in trie. Also , I think Striver uses term Create a new trie every time , which is basically a new node. Trie is only 1 , it's just new reference nodes of that trie that we create every time. See the complete version :- #include using namespace std; struct Node{ Node* links[26]; int cntEndsWith = 0; int cntPrefix = 0; bool containsKey(char &ch){ return links[ch - 'a'] != NULL; } void put(char &ch , Node* node){ links[ch - 'a'] = node; } Node* get(char &ch){ return links[ch - 'a']; } void increasePrefix(){ cntPrefix++; } void increaseEnd(){ cntEndsWith++; } void decreasePrefix(){ cntPrefix--; } void decreaseEnd(){ cntEndsWith--; } int getEndCount(){ return cntEndsWith; } int getPrefixCount(){ return cntPrefix; } }; class Trie{ private: Node* root; public: Trie(){ root = new Node(); } void insert(string word){ Node* node = root; for(int i=0; icontainsKey(word[i]) ){ node->put(word[i] , new Node()); } node = node->get(word[i]); node->increasePrefix(); } node->increaseEnd(); } int countWordsEqualTo(string word){ Node* node = root; for(int i=0; icontainsKey(word[i]) ){ node = node->get(word[i]); } else return 0; } return node->getEndCount(); } int countWordsStartingWith(string word){ Node* node = root; for(int i=0; icontainsKey(word[i]) ){ node = node->get(word[i]); } else return 0; } return node->getPrefixCount(); } bool erase(string word){ if( countWordsEqualTo(word) == 0 ) return false; Node* node = root; for(int i=0; iget(word[i]); node->decreasePrefix(); } node->decreaseEnd(); return true; } }; int main(){ Trie t; t.insert("apple"); t.insert("apple"); t.insert("apps"); t.insert("apps"); t.insert("apxl"); t.insert("bgmi"); cout
@abhisheksahu4428
@abhisheksahu4428 2 жыл бұрын
you explained very easily. "understood"
@prashantmaurya9635
@prashantmaurya9635 Жыл бұрын
Thanks bro, I have solved this ques of my own without viewing this video because of previous one.
@dhirendrasingh6071
@dhirendrasingh6071 Жыл бұрын
So grateful for these videos
@sanbidrc
@sanbidrc 2 жыл бұрын
11:10 Man, the energy ❤️⚡
@karthikeyansivakkumar5075
@karthikeyansivakkumar5075 2 жыл бұрын
understood Sir. Thanks a lot.
@_-6912
@_-6912 2 жыл бұрын
understood and thank you Striver.
@anshulsharma3137
@anshulsharma3137 2 жыл бұрын
Very well Understood bro 👍
@msteja
@msteja 2 жыл бұрын
I watched ur free ka tree series - the BEST on KZfaq undoubtedly covering lots of problems ! Hope u do same justice with this playlist also 😊
@ayushbhandarkar8394
@ayushbhandarkar8394 Жыл бұрын
Understood !! Raj sir you are just ab amazing teacher !
@Whyush7
@Whyush7 Жыл бұрын
aur bhai.. nakli ayush
@ayushbhandarkar8394
@ayushbhandarkar8394 Жыл бұрын
@@Whyush7 kya nakkli.. tu udhar bhi agaya 😂
@AnkitGupta-tp3ln
@AnkitGupta-tp3ln Жыл бұрын
Understood very well!
@aishwaryaranghar3385
@aishwaryaranghar3385 2 жыл бұрын
understood!! a correction, we can actually remove the nodes. But thankss...helped a lot
@vesperbeats6673
@vesperbeats6673 Жыл бұрын
Your playlists are great bhai
@chirag7694
@chirag7694 2 жыл бұрын
21:38 initially i had had this doubt that we must check if it present or not but now clear
@aishwaryaranghar3385
@aishwaryaranghar3385 2 жыл бұрын
thanks
@codingmickey
@codingmickey 10 ай бұрын
super OP explanation sir Thanks alot..
@yashsingh9121
@yashsingh9121 2 жыл бұрын
Hey Striver! In the code for erase function, we should not write the if else condition, as let's say the ith char is not in the trie but all the chars from 0 till i-1 were there, then what we doing is we are reducing the prefix count there which we shouldn't as the word doesn't exist. We should check before hand and if the word is not there we shouldn't do anything else we erase it.
@tripti_
@tripti_ 2 жыл бұрын
hey! but it says that we are erasing with the assumption that word does exist, otherwise we'll definitely have to make some checks
@yashsingh9121
@yashsingh9121 2 жыл бұрын
@@tripti_ Yeah!
@jaisamtani303
@jaisamtani303 2 жыл бұрын
@@yashsingh9121, Instead of having a endsWith property for each trieNode, we can have a static Map wordCounts which has word as key & its count as value. Whenever you have completed a word, just increment its count in the above map instead of incrementing endsWith. Eg: Map = {"apple" : 2, "apps" :2} Advantages of Map: Now for 3rd functionality i.e countWordsEqualTo(), we don't have to traverse Trie, instead we can simply check word in Map and return its count thus reducing TC from O(N) to O(1). For 5th functionality i.e erase() function we can just check if word exist in map, if yes then only we will traverse trie and reduce prefixCount for each character. If not then we simply return and the issue pointed by you is resolved. Thus Map storing is much better option than endsWith!
@036_md.omarfaruq5
@036_md.omarfaruq5 2 жыл бұрын
Tremendous effort given by the boss, understood as always :)
@berkant8074
@berkant8074 2 жыл бұрын
perfect explanation
@ankurverma6289
@ankurverma6289 Жыл бұрын
Won't we need to delete a node after erasing a word, if that node has 0 word ending and 0 prefix counts, to avoid memory leak?
@kushalkumar5028
@kushalkumar5028 Жыл бұрын
Yes, we need to erase the node links as well. For that we can use a stack and store all the TrieNode addresses . Now pop the addresses and delete them until their prefix_counts equals 0
@UECAshutoshKumar
@UECAshutoshKumar 3 ай бұрын
Thank you 🙏
@rujwideshmukh5382
@rujwideshmukh5382 2 жыл бұрын
Amazing!!!!!!
@iampatelajeet
@iampatelajeet Жыл бұрын
understood everything bhai.
@utkarsh_108
@utkarsh_108 2 жыл бұрын
understoooooooooooooood bhaiya. thanks :)
@vinayakkumar5612
@vinayakkumar5612 2 жыл бұрын
Congrats for getting offer from fb london and google Warsaw...Can you share the full procedure about how you make it there!! How you got offer from there and how we people can join after being from tier 3 clge
@RyanKOnk
@RyanKOnk 2 жыл бұрын
You can't, Vinayak. It was through a refferal.
@vinayakkumar5612
@vinayakkumar5612 2 жыл бұрын
@@RyanKOnk how you know it was from referral?
@RyanKOnk
@RyanKOnk 2 жыл бұрын
@@vinayakkumar5612 from Twitter space convo.
@vinni4742
@vinni4742 Жыл бұрын
what if the given word not present in Trie like applesauce is given for erase function???
@jobsjobs1769
@jobsjobs1769 2 жыл бұрын
To check if a word ends with a given suffix, I believe we must create a Suffix Tree. Not very sure how your CountWordsEnd() works here. Any help shall be much appreciated. Thank you Striver.
@takeUforward
@takeUforward 2 жыл бұрын
Here ends actualy means complete word 😅
@jaisamtani303
@jaisamtani303 2 жыл бұрын
@@takeUforward, Instead of having a endsWith property for each trieNode, we can have a static Map wordCounts which has word as key & its count as value. Whenever you have completed a word, just increment its count in the above map instead of incrementing endsWith. Eg: Map = {"apple" : 2, "apps" :2} Advantages of Map: Now for 3rd functionality i.e countWordsEqualTo(), we don't have to traverse Trie, instead we can simply check word in Map and return its count thus reducing TC from O(N) to O(1). For 5th functionality i.e erase() function we can just check if word exist in map, if yes then only we will traverse trie and reduce prefixCount for each character. If not then we simply return to avoid partial deletion of characters. Thus Map storing is much better option than endsWith!
@albinthomas9737
@albinthomas9737 2 жыл бұрын
Thanks Brother
@EditorGuru
@EditorGuru 2 жыл бұрын
Understood
@AmandeepSingh-uq3wp
@AmandeepSingh-uq3wp 2 жыл бұрын
understood 👍
@Harshit126
@Harshit126 Жыл бұрын
Understood, thanks
@satyampande684
@satyampande684 2 жыл бұрын
understood!!
@priyadarsinipaikaray4998
@priyadarsinipaikaray4998 2 жыл бұрын
Great sir 🥳
@sohitmaurya4782
@sohitmaurya4782 2 жыл бұрын
Next level explanation bhaiya .Thank you so much for this amazing playlist.
@hemantvardani1436
@hemantvardani1436 Жыл бұрын
Thanks
@rishabhkumar8115
@rishabhkumar8115 2 жыл бұрын
Understoodddddd sir ji!!!!!!
@fearlesscoder2054
@fearlesscoder2054 2 жыл бұрын
Understood ❤
@adarshbadagala
@adarshbadagala 2 жыл бұрын
Thank you so much for such an awesome explanation bhayya. I am having a small doubt can we increment the countPrefix of the root node every time we are inserting a word ( any word ) so that we can get total number of words that are actually present in our trie ?
@sober_junkie5709
@sober_junkie5709 Жыл бұрын
I think you can do that .
@siddheshb.kukade4685
@siddheshb.kukade4685 Жыл бұрын
thanks
@addityasharma6426
@addityasharma6426 Жыл бұрын
understood😊
@aishwaryapani4662
@aishwaryapani4662 Жыл бұрын
understood ❣
@s.g.prajapati3597
@s.g.prajapati3597 2 жыл бұрын
Understood!
@yasharma2301
@yasharma2301 6 ай бұрын
(Space Optimisation) Erase function with delinking of not required nodes public void erase(String word) { TrieNode cur = root; for (char el : word.toCharArray()) { TrieNode next = cur.get(el); next.decrementCharCounter(); if (next.getCharCounter() == 0) { cur.put(el, null); return; } cur = next; } cur.decrementEndCounter(); }
@Yash-uk8ib
@Yash-uk8ib 2 жыл бұрын
sir, what if countEndWith becomes zero after deletion? The nodes are still there right? isn't this a waste of memory?
@faizalam355
@faizalam355 2 жыл бұрын
understood
@dipakgupta3983
@dipakgupta3983 Жыл бұрын
Thanks Striver
@nishankdeep3084
@nishankdeep3084 Жыл бұрын
uderstood bhaiya thank you bhaiya
@iiitkfresher4887
@iiitkfresher4887 Жыл бұрын
Understood SIRR!!
@rishonkumarrahi
@rishonkumarrahi 2 жыл бұрын
🔥
@rev_krakken70
@rev_krakken70 4 ай бұрын
I have one doubt regarding endswith function at 11:28. For ends with you are starting the trie from the first character. But what if we consider words such as Dapps, or Mapps. Where the first character doesn't start with 'a', in this scenario, the given function fails. Can you clarify on that once?
@manoharmanu9240
@manoharmanu9240 Жыл бұрын
Understood 🙌
@mukulbahedia645
@mukulbahedia645 2 жыл бұрын
waiting for next video in trie series, if there is any \o/
@Itsme1n1ly
@Itsme1n1ly 5 ай бұрын
Striver, if there are duplicate entries, then deleteEnd() would merely decrement the count without removing the expected string entirely.
@govindsharma7696
@govindsharma7696 2 жыл бұрын
Understood 👍
@jaiminsolanki5478
@jaiminsolanki5478 2 жыл бұрын
Understood!!!
@chinmaykulkarni7385
@chinmaykulkarni7385 2 жыл бұрын
Thank you so much mann, your explanation is just best❤‍🔥, thanks for this content!
@akankshakasaudhan2666
@akankshakasaudhan2666 2 жыл бұрын
Thank u so much for the awesome explanation. You are the best.🔥🔥
@pranayjain._
@pranayjain._ Жыл бұрын
Understood!
@utkarshmishra6667
@utkarshmishra6667 2 жыл бұрын
Understood.
@prakkikhyathi1214
@prakkikhyathi1214 Жыл бұрын
Understood 🙂
@dreamyme543
@dreamyme543 Жыл бұрын
Understood:)
@jolly_dollyyy
@jolly_dollyyy 2 жыл бұрын
OP!!!!
@lingasodanapalli615
@lingasodanapalli615 11 ай бұрын
I think there is a small mistake in erase() function. We are going on decreasing the prefix but if we dont find a letter in the middle we are returning directly which means the letters which we have decreased so far will have wrong count. We need not check if that letter is present or not. The word which we are given for erasing will be definitely present in the Trie.
@malayparmar504
@malayparmar504 9 ай бұрын
Same query, I think here we are assuming that the word we are trying to erase is a valid word which was inserted in the trie before, hence this solution works.
@ankursharma6084
@ankursharma6084 2 жыл бұрын
The erase word will reduce the prefix even when the word never exists in the trie. So , i think you should check if the word actually exists in the trie and then erase it.
@josephaj8310
@josephaj8310 Жыл бұрын
Yeah so I tried Implementing a recursive function. May be you might find helpful void newErase(string s){ Node *temp = root; bool t = helper(s, 0, temp); if(t){ cout containsChar(s[i])){ temp = root->get(s[i]); temp->startsWith--; t = helper(s, i+1, temp); } else { t = false; } if(t == false){ temp->startsWith++; return false; } else { return true; } }
@aysams2
@aysams2 8 ай бұрын
Understood sir
@supriya_codes
@supriya_codes Жыл бұрын
🤩
@adityakharat4624
@adityakharat4624 2 жыл бұрын
Eagerly waiting for next videos eksat upload kardo sare 8 videos.. Aaj kal me..
@takeUforward
@takeUforward 2 жыл бұрын
Areh ye chuswaha dimag ka dahi kr k rkha hai 😂
@adityakharat4624
@adityakharat4624 2 жыл бұрын
@@takeUforward ik par ab dhyan mat do.. ✌ Padenge likhenge banenge nawab.
@mayanksehrawat9504
@mayanksehrawat9504 Жыл бұрын
UNDERSTOOD
@sapnafulwani5823
@sapnafulwani5823 2 ай бұрын
Understood :D
@satvrii
@satvrii Жыл бұрын
@ashish2386
@ashish2386 2 жыл бұрын
Here in you code for erasing we are returning when the ith character of the string is not found in the trie, but isn't there a problem with the count of the prefix .Since the word was not present and we updated the prefixcounts for the trie nodes. I think the soln should be dfs based in which if the word is found we return along the path and then reduce the prefix count.
@viditsrivastava1747
@viditsrivastava1747 Ай бұрын
you can just add a little check before erasing the word public void erase(String word) { if (countWordsEqualTo(word) == 0) { return; // If the word does not exist, do nothing } TrieNode node = root; for (char ch : word.toCharArray()) { TrieNode child = node.children.get(ch); if (child != null) { child.prefixCount--; if (child.prefixCount == 0) { node.children.remove(ch); return; } node = child; } } node.wordCount--; } this will do fine i guess
@kushagramishra5638
@kushagramishra5638 6 ай бұрын
UnderStood🙏
@srikrishna6595
@srikrishna6595 2 жыл бұрын
Plz drop a oops series in c++ anna..
@ankitpahwa8571
@ankitpahwa8571 2 жыл бұрын
If Arnab Goswami was a DS Algo teacher
@ajitpalsingh606
@ajitpalsingh606 5 күн бұрын
Simple Implementation without alot many functions: #include struct Node { Node *links[26]; int endw = 0; int CountP = 0; bool contains(char ch) { return links[ch - 'a'] != NULL; } Node *put(char ch, Node *node) { links[ch - 'a'] = node; } Node *get(char ch) { return links[ch - 'a']; } }; class Trie { public: Node *root; Trie() { root = new Node(); } void insert(string &word) { Node *node = root; for (int i = 0; i < word.size(); i++) { if (!node->contains(word[i])) { node->put(word[i], new Node()); } node = node->get(word[i]); node->CountP++; // count prefix } node->endw++; // word completed } int countWordsEqualTo(string &word) { Node *node = root; for (int i = 0; i < word.size(); i++) { if (node->contains(word[i])) { node = node->get(word[i]); } else return 0; } // if(node->getEnd()) return node->endw; } int countWordsStartingWith(string &word) { Node *node = root; for (int i = 0; i < word.size(); i++) { if (node->contains(word[i])) { node = node->get(word[i]); } else return 0; } // if(node->getEnd()) return node->CountP; } void erase(string &word) { // word always exist Node *node = root; for (int i = 0; i < word.size(); i++) { if (node->contains(word[i])) { node = node->get(word[i]); // will contain node->CountP--; // removing characters } else return; } node->endw--; // word removed } };
@ayushsingh2721
@ayushsingh2721 Жыл бұрын
Superb content ;) #striver
@ANURAGSINGH-nl2ll
@ANURAGSINGH-nl2ll 10 ай бұрын
understand
@zahidgul6337
@zahidgul6337 4 ай бұрын
how would you know what is the trie of l and s when it braches? can be both sides
@shashankdaksh7554
@shashankdaksh7554 2 жыл бұрын
Felt soo good to know that you are joining one of the biggest IT firm. But please dont leave us behind
@adrijsharma8404
@adrijsharma8404 Жыл бұрын
in the fucntion erase, the statement "reducePrefix" must be before the get(word[i]) because we need to reduce the prefix for all node, including root. Can you explain more about this? Firstly, am I even right?
@harshdeep7312
@harshdeep7312 Жыл бұрын
striver u beauty big bro
@nithishb.m3530
@nithishb.m3530 2 жыл бұрын
How do we update CW & CP , if more than one letter is there in node. eg : if words are apple and ample. Second node will have letters p & m ..CP for both must be different
@EditorGuru
@EditorGuru 2 жыл бұрын
We are updating the CP in the link node of p and m so there will not be any problem.
@shubhammishra1225
@shubhammishra1225 2 жыл бұрын
Hi Raj , On website Both Link 1 and Link 2(Usually Leetcode question) are same .
@ARSHADKHAN-hc6pb
@ARSHADKHAN-hc6pb 2 жыл бұрын
Bhai please make the DSA series in hindi language also 🙏
@hue.huehuehue
@hue.huehuehue Жыл бұрын
how do you make this Trie code work for both uppercase and lowercaase letters
@_YuvaKumarIrigi
@_YuvaKumarIrigi Жыл бұрын
Sir Why don't we increase the value ---> ew=0,cp=0 at the root node
L3. Longest Word With All Prefixes | Complete String | Trie
25:31
take U forward
Рет қаралды 66 М.
L6. Maximum XOR of Two Numbers in an Array | C++ | Java
36:17
take U forward
Рет қаралды 69 М.
ОСКАР vs БАДАБУМЧИК БОЙ!  УВЕЗЛИ на СКОРОЙ!
13:45
Бадабумчик
Рет қаралды 4,8 МЛН
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 43 МЛН
Каха и суп
00:39
К-Media
Рет қаралды 4,3 МЛН
L1. Implement TRIE | INSERT | SEARCH | STARTSWITH
31:25
take U forward
Рет қаралды 271 М.
Live Mock Interview with @Striver | MAANG Format | GeeksforGeeks
53:14
Intel's CPUs Are Failing, ft. Wendell of Level1 Techs
23:59
Gamers Nexus
Рет қаралды 303 М.
Valorant Tips And Tricks Sent By You - Part 63
9:35
MrLowlander
Рет қаралды 41 М.
VCT Pacific Stage 2: PRX vs RRQ | Voice Comms
11:22
Paper Rex
Рет қаралды 144 М.
How to Start Leetcode in 2024 (as a beginner)
8:45
Ashish Pratap Singh
Рет қаралды 729 М.
The Trie Data Structure (Prefix Tree)
21:07
Jacob Sorber
Рет қаралды 74 М.
All about the new TUF and TUF+
13:37
Striver
Рет қаралды 97 М.
ОСКАР vs БАДАБУМЧИК БОЙ!  УВЕЗЛИ на СКОРОЙ!
13:45
Бадабумчик
Рет қаралды 4,8 МЛН