752. Open the Lock | BFS | Graph | Time Complexity | Why not DP?

Sdílet
Vložit
  • čas přidán 20. 04. 2024
  • In this video, I'll talk about how to solve Leetcode 752. Open the Lock | BFS | Graph | Time Complexity | Why not DP?
    Let's Connect:
    📱Discord (Join Community) : / discord
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / ez.pz.dsa
    💻 Twitter - / aryan_mittal007
    🤖 Github: github.com/aryan-0077
    About Me:
    I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✨ Timelines✨
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Komentáře • 37

  • @shivchauhan795
    @shivchauhan795 Před 3 měsíci +12

    Hey don't get demotivated. You really explain all the questions in very good way. From last 2 month i'm daily watching your videos whenever I get doubt while solving daily leetcode question.
    Your dedication of how you record the videos early morning with such a great explanation is unbelievable.
    Keep up the good work. You will surely get reach with this consistency.
    Looking forward to meet you some day, it will be nice.

  • @sarthakrana5658
    @sarthakrana5658 Před 3 měsíci +8

    "Lavel sbke niklenge" .... Good use of meme 😂

  • @tusharsinghal1333
    @tusharsinghal1333 Před 3 měsíci +7

    You are putting so much effort in these videos.
    keep up the good work bro.

  • @bhavaygoel
    @bhavaygoel Před 3 měsíci +3

    ive not seen any channel put that much effort everyday. keep up the work bro!

  • @codingkart245
    @codingkart245 Před 3 měsíci +1

    BROO!!! YOU JUST KILLED IT!!!! Keep making videos like this!!

  • @Jazzimus
    @Jazzimus Před 3 měsíci +2

    bhaiya aap goated ho never forget

  • @shreejeshjballal767
    @shreejeshjballal767 Před 3 měsíci +2

    Great Explanation ✨.Thank you!

  • @ShubhamMIshra-hv5nz
    @ShubhamMIshra-hv5nz Před 3 měsíci

    I love your videos Aryan, i watch it on a daily basis.

  • @niteshkhanna690
    @niteshkhanna690 Před 3 měsíci

    Your code is very clean and clear

  • @akasakasad
    @akasakasad Před 3 měsíci

    keep up the good work my man

  • @wilhelmrudolphfittig3577
    @wilhelmrudolphfittig3577 Před měsícem

    good keep it up !

  • @sameera2426
    @sameera2426 Před 3 měsíci

    great explanation

  • @kiranjeetkaur4955
    @kiranjeetkaur4955 Před 3 měsíci

    Awesome.. idk why you get very less likes.. you deserve a lot more

  • @vanshikaahuja766
    @vanshikaahuja766 Před 3 měsíci +3

    ngl, You are my inspiration.

  • @Vishal-qb3wz
    @Vishal-qb3wz Před 3 měsíci

    Great Content.
    Keep Doing!!!!

  • @tusharsinghal1333
    @tusharsinghal1333 Před 3 měsíci

    The internal while loop for each level seemed a little confusing to me, so i did it a little differently by making a queue of pair which keeps a pair of {currentString, level} and that did the job in a single while loop, similar to traditional BFS.

  • @harshal8781
    @harshal8781 Před 3 měsíci +2

    ❣💞❣

  • @asthajain2511
    @asthajain2511 Před 3 měsíci

    great content 😌

  • @HaiAnhDuong-ew2fl
    @HaiAnhDuong-ew2fl Před 3 měsíci

    nice bro

  • @k.satish3663
    @k.satish3663 Před 3 měsíci

    Nice explanation.

  • @rahulsihara8946
    @rahulsihara8946 Před 3 měsíci

    Amazing explanation as always

  • @nagasrisaichaitanyakolluri8173
    @nagasrisaichaitanyakolluri8173 Před 3 měsíci +1

    Thanks bro

  • @yashyenurkar9383
    @yashyenurkar9383 Před 3 měsíci

    great solution and explanation🙌

  • @mathy642
    @mathy642 Před 3 měsíci

    nice explanation!!

  • @kuldeepsaini460
    @kuldeepsaini460 Před 3 měsíci

    Great Explanation please open a Hindi Channel also

  • @Noob_Coder1234
    @Noob_Coder1234 Před 3 měsíci

    TIME AND SPACE COMPLEXITY PART WAS LIT!!

  • @TON-108
    @TON-108 Před 3 měsíci +2

    Lyaval sabke nikalenge 😌😌😌

  • @shubham_paliwal
    @shubham_paliwal Před 3 měsíci

    Thanks a ton for making us understand in the best possible way! 💯...It takes a lot of efforts, guts, and a very deep understanding to do so 🔥.

  • @bharatmehta30
    @bharatmehta30 Před 3 měsíci

    Level sabke niklenge.

  • @vickyroy3595
    @vickyroy3595 Před 3 měsíci

    100k soon!!!!❤

  • @ujjwalrockriser
    @ujjwalrockriser Před 3 měsíci

    Sorry, bas BFS dekha aur video nahi dekha, thank you for the hint.

  • @shreeshdivyamsinha126
    @shreeshdivyamsinha126 Před 3 měsíci

    Yrr aap itna mehnat kar rahe ho.
    App j curve ke starting pe ho bas kuch din aur, aap dekhna 100k bahut jald hojayga. 🙂

  • @jiganeshpatil1472
    @jiganeshpatil1472 Před 3 měsíci +2

    Leavaaal sabke niklenge

  • @wellsonny7987
    @wellsonny7987 Před 2 měsíci

    CFBR

  • @shashanksahu9230
    @shashanksahu9230 Před 3 měsíci

    At first I thought It was a recursion problem, but I was getting wrong answer with it. I still don't understand how you come up with graph instead of recursion

  • @nerdInsaan
    @nerdInsaan Před 3 měsíci

    Java code for reference :
    class Solution {
    public char turnRight(char c){
    return c == '9' ? '0' : (char) ( c + 1);
    }
    public char turnLeft(char c){
    return c == '0' ? '9' :(char) ( c - 1);
    }
    public List nextOptions(String s){
    List options = new ArrayList();
    for(int i = 0 ; i < 4 ; i++ ){
    char [] copy = s.toCharArray();
    copy[i] = turnRight(s.charAt(i));
    options.add(new String(copy));
    copy[i] = turnLeft(s.charAt(i));
    options.add(new String(copy));
    }
    return options;
    }
    public int openLock(String[] deadends, String target) {
    Deque q = new LinkedList();
    Set visited = new HashSet();
    q.offer("0000");
    visited.add("0000");
    Set deadend = new HashSet(Arrays.asList(deadends));

    int level = 0;
    while(!q.isEmpty()){
    int size = q.size();
    while(size-- > 0){
    String curr = q.poll();
    if(curr.equals(target)) return level;
    if(deadend.contains(curr)) continue;
    for(String option : nextOptions(curr)){
    if(!visited.contains(option) && !deadend.contains(curr) ){
    q.offer(option);
    visited.add(option);
    }
    }
    }
    level++;
    }
    return -1;
    }
    }

  • @Helop538
    @Helop538 Před 3 měsíci

    Again