Restore IP Addresses | Recursive Tree | Diagram | META | Leetcode 93

This is the 12th Video of our Strings Playlist.
In this video we will try to solve another very good and popular problem "Restore IP Addresses | Recursive Tree | Diagram | META | Leetcode 93".
Share your learnings on LinkedIn, Twitter (X), Instagram, Facebook(Meta) with the hashtag #codestorywithmik & feel free to tag me.
Problem Name : Restore IP Addresses
Company Tags : META
My solutions on Github : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/restore...
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
0:00 - Intro
0:32 - Understanding Qn
2:35 - Intuition Building
4:47 - Tree Recursive Diagram
17:35 - Interesting Fact
19:19 - Story To Code
29:00 - Time Complexity
32:30 - Live Coding from Story
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish

Пікірлер: 69

  • @atifhu
    @atifhu Жыл бұрын

    what an explanation👏

  • @compiled9787
    @compiled9787 Жыл бұрын

    I urge everyone to watch full ads in his videos and not skip it...This guy deserves this!

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    That’s overwhelming. I want to thank you from the bottom of my heart. That’s very kind ❤️

  • @nagmakhan3165

    @nagmakhan3165

    Жыл бұрын

    True

  • @souravjoshi2293

    @souravjoshi2293

    Жыл бұрын

    Seriously man. I am really gonna do that for this guy. He deserves it.

  • @user-qo6vg5jb6y

    @user-qo6vg5jb6y

    Жыл бұрын

    me using adblocker

  • @oqant0424
    @oqant0424 Жыл бұрын

    Finally wait is over

  • @NatureLover-oq6uc
    @NatureLover-oq6uc Жыл бұрын

    Lovely Explanation...Next level Expalnation....maza hii aagya...

  • @NikhilYadav-cj2jt
    @NikhilYadav-cj2jt Жыл бұрын

    great explanation, huge respect man seriously 👍 keep posting such videos daily and also imp questions from imp topics and interview perspective

  • @AmitSaha_15
    @AmitSaha_154 ай бұрын

    this channel is really underrated.... your explanations are crazy good.... thanks for such great contents ❤❤

  • @nagmakhan672
    @nagmakhan672 Жыл бұрын

    Crisp and perfect. Thanks a lot for the recursive tree explanation and dry run

  • @amanbalhara7365
    @amanbalhara7365 Жыл бұрын

    Learned alot of new things from this video, thankyou so much 🥺. You always made everything so ezz...

  • @rahuljha972
    @rahuljha97221 күн бұрын

    nice explanation

  • @shabananoor9423
    @shabananoor9423 Жыл бұрын

    Wonderful explanation

  • @souravjoshi2293
    @souravjoshi2293 Жыл бұрын

    Man you are just awesome. I just saw you crossed 2k subscribers. Congratulations and soon you will reach 1M trust me

  • @abhinavtomar8518
    @abhinavtomar851810 ай бұрын

    Your explanation is really good bro . Keep bringing such videos

  • @codestorywithMIK

    @codestorywithMIK

    10 ай бұрын

    Thank you so much 😇🙏

  • @khushipandey5144
    @khushipandey51443 ай бұрын

    Mannn!!!🙇🏻‍♀️🙇🏻‍♀️ You're the best 🔥🔥🔥

  • @codestorywithMIK

    @codestorywithMIK

    3 ай бұрын

    🙏🙏❤️❤️😇😇

  • @madhabkafle8898
    @madhabkafle8898 Жыл бұрын

    Congratulations for 2K, Wish you many more in future.👏👏👏

  • @vaibhavgupta973
    @vaibhavgupta973 Жыл бұрын

    you literally made it really easy !!

  • @animesh414
    @animesh414 Жыл бұрын

    you are superbbbb.

  • @JJ-tp2dd
    @JJ-tp2dd Жыл бұрын

    God Level explanation

  • @souravjoshi2293
    @souravjoshi2293 Жыл бұрын

    He is back 🔥

  • @shubhamsandanshiv515
    @shubhamsandanshiv515 Жыл бұрын

    Best best bhai keep going👍

  • @tutuimam3381
    @tutuimam3381 Жыл бұрын

    Thanks a lot

  • @anshika3542
    @anshika3542 Жыл бұрын

    Bestest explanation😇

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Thank you Anshika 😇

  • @ugcwithaddi
    @ugcwithaddi4 ай бұрын

    Dope 🔥

  • @wearevacationuncoverers
    @wearevacationuncoverers Жыл бұрын

    lit

  • @deeparawat8308
    @deeparawat8308 Жыл бұрын

    very helpful!! can you please make a vedio on constraints analysis .(how to take help from constraints in solving questions)

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Thanks Deepa. I have planned to make a video on that too soon. Thanks for watching 😇

  • @Krishna-mz2uk
    @Krishna-mz2uk Жыл бұрын

    Java Solution as per above Approach: class Solution { int n; List result; public boolean valid(String s) { if(s.charAt(0)=='0') return false; if(Integer.parseInt(s)>255)return false; return true; } public void solve(String s,int i,int parts,String cur) { if(parts>4) return; if(parts==4 && i==n) { //remove the dot result.add(cur.substring(0,cur.length()-1)); return; } if(i+1

  • @udaytewary3809
    @udaytewary3809 Жыл бұрын

    Really thankyou bhaiya your explanation helped a lot at first I was not able to even approach the problem but after listening to you for few minutes I began to understand the problem and for that really thankyou bhaiya I will be always great full to you One thing wanted to ask you if this type of question came in online interview then what should we do face that type of situation ?

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Thanks a lot Uday During interviews they generally help also , hints are given if you need But it’s important that you atleast share your thoughts out loud

  • @Krishna-mz2uk
    @Krishna-mz2uk Жыл бұрын

    if (parts>4 ) return ; this condition should be added na otherwise it'll call recursion unnecessarily even when we crossed 4Parts

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Yep you can add it too. Good one 👍🏻

  • @TM-vh1qg
    @TM-vh1qg Жыл бұрын

    god 🛐🛐

  • @podilichaitanyaakhilkumar4911
    @podilichaitanyaakhilkumar4911 Жыл бұрын

    You're awesome. But, Please post videos in English, so that it reaches to wider audience.

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Soon I will try to add subtitles. 😇 And make another video in english too

  • @jaymishra1781
    @jaymishra1781 Жыл бұрын

    If possible end me Java ka code v ek baar dikha diya karo, baki you teach really good. Congratulations for 2k

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Sure ❤️

  • @akshayzade9761
    @akshayzade9761 Жыл бұрын

    Nice approach & Solution If you don't mind can you make 1 video on explaining recursion? Like how generally Recursion are used in leetcode programs, how to think on problems solving from that perspective.. As watching the video I got the hint you will be using recursion but calling recursion 3 times with different parameters etc TBH its hard to trace the calls inside brain n think from that perspective I have started watching this channel start of 2023 I see you release video daily .. It will be tough for you to manage your day IF YOU CAN CREATE VIDEO Then only DO or else its whole fine no issues Thanks Mik 😊

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Hi Akshay, I am soon planning to create playlists on these topics also from scratch. I will just be ok break next month for 3 weeks for travelling, then i will be back again. And definitely i will create videos on what you want. Thanks for watching ❤️❤️❤️

  • @akshayzade9761

    @akshayzade9761

    Жыл бұрын

    ​@@codestorywithMIK - Thanks a lot for your efforts and yaa enjoy your days very well We are not running out 😄Your channel has different uniqueness of "Story To Code" Which makes peeps like me to understand easy You are killing the leetcode discussion section.. Keep it up mate 👍

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Thanks a lot 😇❤️

  • @india9648
    @india9648 Жыл бұрын

    Bro how do u figure out so many things to solve a prob. I am not able to do that 😢 between congrats for 2k bro u deserve more 🔥

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Thank you so much. And regarding approaches, I always believe in making story first. And trust me, with time, it will come to you too. Keep practicing

  • @thevagabond85yt
    @thevagabond85yt5 ай бұрын

    Java code using for-loop-recursion & regex : ``` class Solution { public List restoreIpAddresses(String s) { List result = new ArrayList(); int N= s.length(); if (N>12) return result; //empty List solve(s, 0, N, new StringBuilder(), 0, result); return result; } public void solve(String s, int idx, int N, StringBuilder ipSoFar, int octetCount, List result) { // defining : base or termination condition if ( octetCount == 4 && idx == N ) { String validIP = ipSoFar.substring(0, ipSoFar.length()-1);//removes trailing delimeter '.' result.add(validIP); return; } // exploring different considerations : max 3 possible at each stage for(int r=idx+1; r

  • @drbullah1388
    @drbullah1388 Жыл бұрын

    ❤ Ye kal ke question jaisa hua na bhaiya? Ki ham backtracking karre har step pe, ki lenge ya nahi lenge string ko, agar valid hai to append karenge warna nahi

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Yep, you can call it backtracking too.

  • @shashwats9273
    @shashwats9273 Жыл бұрын

    Itni sari conditions sochna ....fir usko Code me convert krna kaise kr lete ho aap ....ho hi ni pata mujhse ye jitna bhi khud se likhne ka try kr lu .... 😥😭

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Trust me, keep practicing and it will come soon. Never stop 💪

  • @shashwats9273

    @shashwats9273

    Жыл бұрын

    @@codestorywithMIK Ok bhaiya 🥰❤

  • @piyushacharya7696
    @piyushacharya7696 Жыл бұрын

    Bro why on passing string curr by reference in solve() and isValid() gives an error? I am new to c++ so I didn't get it.

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Actually this is this will give error because, you are trying to pass s.substr() which will be of type std::__cxx11::basic_string to &str which is of type std::__cxx11::string& Both are of different type. So, whenever you pass anything by reference, make sure you evaluate the substr (or any operation) and save it in a variable and then pass it. For example : #include using namespace std; void check(string &str) { cout

  • @piyushacharya7696

    @piyushacharya7696

    Жыл бұрын

    @@codestorywithMIK Bro thanks a lot for describing it so properly even in the comment section. May you get millions of subscribers 💪. 🐐 of DSA explanation.

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Thanks a lot Shrijal. Glad it helped ❤️

  • @manishv.8167
    @manishv.8167 Жыл бұрын

    Please don't pause the graph concept playlist and complete it soon, so that we can start with other concept like dp,tree ,etc

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Yep Coming tomorrow

  • @shriyanshjain4444
    @shriyanshjain4444 Жыл бұрын

    Need Help Can anyone tell me where am i wrong class Solution { public: bool isValid(string st){ if(st[0] == '0' || stoi(st) 255) return false; // leading 0 in 2 or 3 size parts AND range check return true; } void solve(string &s, int index, int &n, vector &answer, string ans, int parts){ if(index == n && parts == 4){ ans.pop_back(); // removing last dot . answer.push_back(ans); } if(index+1

  • @Krishna-mz2uk
    @Krishna-mz2uk Жыл бұрын

    We started index from 0 na So why we are using indx+1

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    In C++ substr(idx, length) It includes the current element at idx too. For example : s = “abc” idx = 1 I want to take length of 2 substring s.substr(idx, 2) It will take “bc” i.e. start at idx = 1 And from here take 2 length i.e. “bc” so , idx+2 = 1+2

  • @twi4458

    @twi4458

    Жыл бұрын

    @@codestorywithMIK Thanks for clearification bhaiya, I had the same doubt.

  • @yashgarg3027
    @yashgarg3027 Жыл бұрын

    please help it is showing illeagal character class Solution { public List restoreIpAddresses(String s) { List ans = new ArrayList(); if(s.length() > 12){ return ans; } int n = s.length(); String p = ""; helper(p,s,ans,0,0,n); return ans; } static void helper(String p,String s,List ans,int parts,int index,int n){ if(index == n && parts == 4){ ans.remove(ans.size()-1); ans.add(p); return; } if(index+1

  • @oqant0424
    @oqant0424 Жыл бұрын

    code fat jane ka matlab?

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    It means “error ajaega” Code fatna is like a slang used in corporate 😅

  • @oqant0424

    @oqant0424

    Жыл бұрын

    @@codestorywithMIK ok😅

  • @cacklouncle
    @cacklouncle9 ай бұрын

    My approach: Only 3 options are possible when we are at an index i of str 1. Only option is to take the char at index i. 2. Only option is to put a dot. 3. Exploring both above options class Solution: def f(self,i,n,temp,result,s,last,dotcount): if dotcount >3: return if i == n: if dotcount == 3: result.append(temp) return if last == "":#only_option_is_to_take_the_current_character self.f(i+1,n,temp+s[i],result,s,last+s[i],dotcount) elif last == '0' or int(last+s[i])>255: #only_option_is_to_put_a_dot self.f(i,n,temp+'.',result,s,"",dotcount+1) else:#exploring_both_options_(taking_current_char_and_putting_dot) self.f(i+1,n,temp+s[i],result,s,last+s[i],dotcount) self.f(i,n,temp+'.',result,s,"",dotcount+1) def restoreIpAddresses(self, s: str) -> List[str]: slen = len(s) result = [] if slen>12: return result self.f(0,slen,"",result,s,"",0) return result