Design Browser History | Made Easy | META | Leetcode 1472

  Рет қаралды 3,739

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 57
@ankitsingh6624
@ankitsingh6624 Жыл бұрын
Aap itna acha teach karte ho ki repeat dekhta hu question already karne ke baad bhi raretalent.🙇🙇
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you so much Ankit ❤️
@amitshankhwar2542
@amitshankhwar2542 Жыл бұрын
Soo true ..
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Apologies for the delay today guys. Have been travelling this weekend. Hope you guys will understand ❤❤❤
@UECAshutoshKumar
@UECAshutoshKumar 7 ай бұрын
Thank you 😊
@anuppatankar4294
@anuppatankar4294 Жыл бұрын
By seeing your video today I was able to code it myself. Your daily uploads are really helpful for improving my skills. Keep up the great work! 👍🏻
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot ❤
@molyoxide8358
@molyoxide8358 Жыл бұрын
In the morning, I saw today's problem & left it(too lazy), but after this video removed my laziness & I went forward to solve this challenge. Thanks again for your guidance.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Excellent!❤
@utsabkundu27
@utsabkundu27 Жыл бұрын
Code in Java: class BrowserHistory { Stack past=new Stack(); Stack future=new Stack(); String curr; public BrowserHistory(String homepage) { curr=homepage; } public void visit(String url) { past.push(curr); curr=url; future=new Stack(); } public String back(int steps) { while(steps>0 && past.size()>0) { future.push(curr); curr=past.peek(); past.pop(); steps--; } return curr; } public String forward(int steps) { while(steps>0 && future.size()>0) { past.push(curr); curr=future.peek(); future.pop(); steps--; } return curr; } }
@Whirlwind03
@Whirlwind03 Жыл бұрын
Amazing Explanation brother was literally waiting for your video
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you so much Sajan
@wearevacationuncoverers
@wearevacationuncoverers Жыл бұрын
One of the finest explanations on this.
@shikharpandya4927
@shikharpandya4927 4 ай бұрын
Anyone who wants to practise dsa like listening a story this is the guy u should follow :)
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
Thanks for working for us during weekends also bro. Respect hai tumhare lie
@rajgupta5355
@rajgupta5355 Жыл бұрын
Bhaiya this is superb....
@tutuimam3381
@tutuimam3381 Жыл бұрын
Thanks a lot
@anshumantripathy115
@anshumantripathy115 Жыл бұрын
At 5:50 , when "BrowserHistory" is called the current is initialized and the url is also added to the back stack. So, the top of the stack is actually the value of current. Later also the same thing is done in the story, the top of the back stack is the value of current but in the code you have done different.
@anshumantripathy115
@anshumantripathy115 Жыл бұрын
A/c to the story this should be the code, but I am getting error class BrowserHistory { public: stack past; stack future; string current; BrowserHistory(string homepage) { current = homepage; past.push(homepage); } void visit(string url) { future = stack(); past.push(url); current = url; } string back(int steps) { while (steps > 0 && !past.empty()) { future.push(current); past.pop(); current = past.top(); steps--; } return current; } string forward(int steps) { while (steps > 0 && !future.empty()) { past.push(future.top()); future.pop(); current = past.top(); steps--; } return current; } };
@vedantdeshmukh1778
@vedantdeshmukh1778 Жыл бұрын
@@anshumantripathy115 I am facing same error.
@anshumantripathy115
@anshumantripathy115 Жыл бұрын
@@vedantdeshmukh1778 class BrowserHistory { public: stack past; stack future; string current; BrowserHistory(string homepage) { current = homepage; past.push(homepage); } void visit(string url) { future = stack(); past.push(url); current = url; } string back(int steps) { while (steps > 0 && !past.empty()) { /* code */ future.push(current); past.pop(); if(!past.empty()){ current = past.top(); }else{ past.push(current); future.pop(); } cout
@anshumantripathy115
@anshumantripathy115 Жыл бұрын
@@vedantdeshmukh1778 There are some corner cases which needs to be checked. Check the new code I shared. This one works, but it becomes a bit complex using this approach rather we should follow the code shared by MIK.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
You are right Anshuman. Missed to cover corner cases in explanation. Thank you so much for pointing this out
@Aditrash-n5j
@Aditrash-n5j Жыл бұрын
Instead of using "curr" you can use "peek" of stack to return values, like this class BrowserHistory { Stack backward; Stack forward; public BrowserHistory(String homepage) { backward = new Stack(); forward = new Stack(); backward.push(homepage); } public void visit(String url) { // Clear forward while(!forward.isEmpty()) forward.pop(); backward.push(url); } public String back(int steps) { // Pop from backward into forward while(backward.size() != 1 && steps != 0){ forward.push(backward.pop()); steps--; } return backward.peek(); } public String forward(int steps) { // Pop form forward into backword while(!forward.isEmpty() && steps != 0){ backward.push(forward.pop()); steps--; } return backward.peek(); } }
@molyoxide8358
@molyoxide8358 Жыл бұрын
Yeah It's Sunday tomorrow we need 2 other approaches too. A Humble request from a Coder to Coder🥰 And also if you're free please shed some light on leetcode - 1019 as I requested in the previous video.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Sure. Travelling this weekend. Will make for sure next week
@rajgupta5355
@rajgupta5355 Жыл бұрын
Bhaiya other 2 approaches k liye please video bnaiyega
@Imrockonn
@Imrockonn Жыл бұрын
@KishanSingh-vc3re
@KishanSingh-vc3re 4 ай бұрын
Do they ask such questions in Dsa rounds or only in system design interviews
@waghakshay540
@waghakshay540 10 ай бұрын
sir canyou please make a dryrun video for this code..I have some confusion
@sonalipatro2087
@sonalipatro2087 Жыл бұрын
please make video on other two approaches as well
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Sure. Travelling this weekend. Will make for sure next week
@Ramneet04
@Ramneet04 Жыл бұрын
I waa able to code with two stack approach, hey well dlubly ll is more optimise???
@aryanvashishtha0001
@aryanvashishtha0001 Жыл бұрын
Bro explaination is Top-notch but pls try to improve the quatlity of video if possible....
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Actually the quality will improve after a while as it takes some time to upload full quality from KZbin And thank you so much for your kind words ❤❤❤
@udaykumarchetla6205
@udaykumarchetla6205 Жыл бұрын
Bro can u upload videos for today's contest last 2 problems?
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
Waiting for today's Leetcode
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Being uploaded
@YashSinghal
@YashSinghal Жыл бұрын
daab diya 😅😆
@hirenjoshi6073
@hirenjoshi6073 Жыл бұрын
Hi Bro! Make it using Doubly Linked List
@swapnilnangare5805
@swapnilnangare5805 Жыл бұрын
Mazhar bhai ek baar word break bhi samaza do pls. Trie ke saath dp samazne ke liye hard ja rahi hain. lots of love.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
That’s a wonderful Qn swapnil. Noted. Let me cover that too. Thanks again for pointing
@omkarjadhav848
@omkarjadhav848 9 ай бұрын
Bhaiya using doubly linked list bhi samza dena please
@whodatsaken
@whodatsaken 3 ай бұрын
great explanation bro. loved it for those who want DLL implementation class BrowserHistory { public: struct ListNode{ string data; ListNode* prev; ListNode* next; ListNode(string x){ data=x; prev=nullptr; next=nullptr; } }; ListNode* head=nullptr; BrowserHistory(string homepage) { head=new ListNode(homepage); } void visit(string url) { ListNode* temp=new ListNode(url); temp->prev=head; head->next=temp; head=head->next; } string back(int steps) { while(head->prev!=nullptr and steps){ head=head->prev; steps--; } return head->data; } string forward(int steps) { while(head->next!=nullptr and steps){ head=head->next; steps--; } return head->data; } };
@Babu_Vishaal
@Babu_Vishaal Жыл бұрын
bro ...! ho sake to job opening ke update bta diya kro.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Sure Vishal
@aadityabuchale15
@aadityabuchale15 Жыл бұрын
Bhiya bohot late kr diya.. its okay i know you might be in any work.. btw thanks for the video..
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you for understanding Aaditya ❤️
@somsk56
@somsk56 2 ай бұрын
Sir , I GUESS STACK APPROACH , IT IS NOT OK FOR INTERVIEW RIGHT ? SO WHICH ONE I HAVE TO FOLLOW PLEASE TELL ME
@codestorywithMIK
@codestorywithMIK 2 ай бұрын
You can use any approach. Totally depends on what the interviewer wants.
@somsk56
@somsk56 2 ай бұрын
@@codestorywithMIK If you are interviewer then what do you prefer sir ?
@amir26ansari
@amir26ansari Жыл бұрын
Good voice , whats ur name
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks Amir. It’s Mazhar
@kumarsaurabh5449
@kumarsaurabh5449 Жыл бұрын
class BrowserHistory { public: vectormp; int curr; BrowserHistory(string homepage) { mp.push_back(homepage); curr=0; } void visit(string url) { mp.erase(mp.begin()+curr+1,mp.end()); mp.push_back(url); curr++; } string back(int steps) { curr=max(0,curr-steps); return mp[curr]; } string forward(int steps) { curr=min((int)mp.size()-1,curr+steps); return mp[curr]; } }; // vector approach
@MakeuPerfect
@MakeuPerfect Жыл бұрын
bhaiya aj ka daily challenge ??
@codestorywithMIK
@codestorywithMIK Жыл бұрын
It will come soon . Sorry for the delay. Have been travelling this weekend. But it will be uploaded today. Few things : 1) The best part about today’s qn is that it can be solved using already used template of TRIE that I taught. It will be fun ✌️❤️
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Being uploaded now
LEETCODE(FAANG)-REMOVE OUTERMOST PARENTHESIS
17:56
KungfuNaman
Рет қаралды 17 М.
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 51 МЛН
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 88 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 166 МЛН
Design a Food Rating System | Clean Approach | Leetcode-2353
25:33
codestorywithMIK
Рет қаралды 4 М.
Design HashSet | Full Details | GOOGLE | Leetcode-705 | Live Code
26:17
codestorywithMIK
Рет қаралды 4,1 М.
Design Browser History - Leetcode 1472 - Python
13:30
NeetCodeIO
Рет қаралды 20 М.
How I Failed the Google Coding Interview (and lessons I learned)
14:24
Design Browser History | EP 21
14:21
Fraz
Рет қаралды 14 М.
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 51 МЛН