All Nodes Distance K In A Binary Tree - Performing Bidirectional Search On A Tree Using A Hashtable

  Рет қаралды 82,348

Back To Back SWE

Back To Back SWE

Күн бұрын

Free 5-Day Mini-Course: backtobackswe.com
Try Our Full Platform: backtobackswe.com/pricing
📹 Intuitive Video Explanations
🏃 Run Code As You Learn
💾 Save Progress
❓New Unseen Questions
🔎 Get All Solutions
Question: You are given 3 things. The root of a binary tree, a single start node in the binary tree, and a number k. Return all nodes that are k "hops" away from the start node in the binary tree. Return a list of the values held at those nodes.
Complexities
n = total amount of nodes in the binary tree
m = total edges
Time: O( n + m )
This is standard to Breadth First Search. We upper bound the time by the number of nodes we can visit and edges we can traverse (at maximum).
Space: O( n )
We have a hashtable upper bounded by n mappings, a mapping to each node's parent.
++++++++++++++++++++++++++++++++++++++++++++++++++
HackerRank: / @hackerrankofficial
Tuschar Roy: / tusharroy2525
GeeksForGeeks: / @geeksforgeeksvideos
Jarvis Johnson: / vsympathyv
Success In Tech: / @successintech

Пікірлер: 465
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 26 МЛН
All nodes distance K in binary tree | Leetcode #863
12:45
Techdose
Рет қаралды 8 М.
Lowest Common Ancestor Between 2 Binary Tree Nodes (A Recursive Approach)
20:30
Network Flows: Max-Flow Min-Cut Theorem (& Ford-Fulkerson Algorithm)
21:56
How AIs, like ChatGPT, Learn
8:55
CGP Grey
Рет қаралды 10 МЛН
Xiaomi SU-7 Max 2024 - Самый быстрый мобильник
32:11
Клубный сервис
Рет қаралды 552 М.
Samsung laughing on iPhone #techbyakram
0:12
Tech by Akram
Рет қаралды 7 МЛН
Rate This Smartphone Cooler Set-up ⭐
0:10
Shakeuptech
Рет қаралды 6 МЛН