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
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
please also solve this question: Selling Pieces of Wood
Thanks 😊, I learnt many concepts Today 😊.
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".
Thank you sir
I was actually stucked with this test case ❤❤
Thank You sir for such beautiful explanation ❣❤❤
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
love from colombia❤
World tour 🙌
Amazing and clear explanation as always
@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
Padhe likhe log kahate hai backtracking... Ye epic tha 😂
gjb explain sir
Can you join source code with it. As github repo or ss.
😍😍😍
kuch nahi samjh me aaya sir
@@thAsciNileshPal trees data structure padhne ke baad trees ke questions solve kro.. iss playlist se padh lo pehle...
ruclips.net/p/PLQ7ZAf76c0ZM7k15502F8oSiRSQyBX6R0&si=rA31NUv0J_3MB-r_