2096. Step-By-Step Directions From a Binary Tree Node to Another | Leetcode POTD | DSA | Hindi

Поделиться
HTML-код
  • Опубликовано: 22 авг 2024
  • (Please watch LCA, before watching this video)
    LCA:
    • 236. Lowest Common Anc...
    Problem Name:
    2196. Create Binary Tree From Descriptions
    Problem Statement:
    You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.
    Find the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:
    'L' means to go from a node to its left child node.
    'R' means to go from a node to its right child node.
    'U' means to go from a node to its parent node.
    Return the step-by-step directions of the shortest path from node s to node t.
    Problem Link:
    leetcode.com/p...
    Graph Playlist:
    • Graph Data Structure S...
    Java Plus DSA Placement Course Playlist:
    • Java and DSA Course Pl...
    Java Plus DSA Sheet:
    docs.google.co...
    Notes:
    github.com/Tiw...
    Telegram Link:
    shashwattiwari...
    Ultimate Recursion Series Playlist:
    • Recursion and Backtrac...
    Instagram Handle: (@shashwat_tiwari_st)
    shashwattiwari...
    Samsung Interview Experience:
    • I cracked Samsung | SR...
    Company Tags:
    Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
    Timestamp:
    0:00 - Introduction
    #ShashwatTiwari #coding​​ #problemsolving​

Комментарии • 18

  • @shashwat_tiwari_st
    @shashwat_tiwari_st  Месяц назад +3

    Please watch LCA before watching this video. Do like the video, if you understood the solution. Like target for this video is 100. ☺☺ ruclips.net/video/m9NKcTvrhSc/видео.html

    • @floatingpoint7629
      @floatingpoint7629 Месяц назад

      please also solve this question: Selling Pieces of Wood

  • @RohitKumar-dz8dh
    @RohitKumar-dz8dh Месяц назад +1

    Thanks 😊, I learnt many concepts Today 😊.

  • @shashwat_tiwari_st
    @shashwat_tiwari_st  Месяц назад +1

    22:43
    If anyone is thinking about the edge case where one of the target node is the ancestor...
    for cases where lca(p,q) = p or lca(p,q) = q. Path of one of the node will be "commonPath" and Path of second node will be "commonPath" + "some additional moves". Example:
    let's say p is the ancestor node. That means ancestor(p,q) = p.
    path from root to p is "LLRRLR"
    path from root to q is "LLRRLRLLRR"
    Now as you can see path of p is actually the prefix of path of q. Still our logic remains same, replace path of p with. "U" and add leftover path of q. So output will be "UUUUUULLRR".

    • @saurabhchamoli5204
      @saurabhchamoli5204 Месяц назад

      Thank you sir
      I was actually stucked with this test case ❤❤

  • @anujpal574
    @anujpal574 Месяц назад

    Thank You sir for such beautiful explanation ❣❤❤

  • @a3rdtierguy864
    @a3rdtierguy864 Месяц назад +1

    aBLE TO SOLVE TODAY POTD FIRST I GOT MEMORY LIMITED EXCEDDED THEN USE REFRENCE AND BACKTRACK TO OPTIMISE IT AND EASILY SOLVED IT BUT TAKE 1.5 HR IN THINKING ABOUT EXCEDEDED

  • @GirjeshSharma-zv3xo
    @GirjeshSharma-zv3xo Месяц назад

    love from colombia❤

  • @saisree04
    @saisree04 Месяц назад

    Amazing and clear explanation as always

  • @memes438
    @memes438 Месяц назад +1

    @shashwat_tiwari_st Sir Please update the Java Plus DSA sheet with the lecture's links and also update the playlist by adding the new lectures after the tree topic and also add the recursion lectures also

  • @akashraj9952
    @akashraj9952 Месяц назад

    Padhe likhe log kahate hai backtracking... Ye epic tha 😂

  • @user-oi5ls4rs5g
    @user-oi5ls4rs5g Месяц назад

    gjb explain sir

  • @Aryabhatta_91
    @Aryabhatta_91 Месяц назад

    Can you join source code with it. As github repo or ss.

  • @PiyushSharma-we8yd
    @PiyushSharma-we8yd Месяц назад

    😍😍😍

  • @thAsciNileshPal
    @thAsciNileshPal Месяц назад

    kuch nahi samjh me aaya sir

    • @shashwat_tiwari_st
      @shashwat_tiwari_st  Месяц назад

      @@thAsciNileshPal trees data structure padhne ke baad trees ke questions solve kro.. iss playlist se padh lo pehle...

    • @shashwat_tiwari_st
      @shashwat_tiwari_st  Месяц назад

      ruclips.net/p/PLQ7ZAf76c0ZM7k15502F8oSiRSQyBX6R0&si=rA31NUv0J_3MB-r_