Really it is very important questions..This question was asked by Paytm in my second technical interview round ..And I could not answer it properly..After that I again saw this question in online coding test of Box8.
@@kautukdwivedi How to print order? Like for node at K distance away it is easy to return the answer array but how to do in this? can you provide the code?
Hope you like the video. For better experience and well organised content sign up on nados.io Don't forget to follow us on Instagram instagram.com/pepcoding/
It's because static global variable retains it's memory when tests are run in sequence. That's the reason same test will pass when run alone. You can initialize maxTime=0 (at line 52 according to above code), before giving a call to burningTree_
Really it is very important questions..This question was asked by Paytm in my second technical interview round ..And I could not answer it properly..After that I again saw this question in online coding test of Box8.
kaffi common question ha
asked multiple times in amazon
Sometimes they ask to print order of burning too.
@@kautukdwivedi How to print order? Like for node at K distance away it is easy to return the answer array but how to do in this? can you provide the code?
Explanation of last question was so good that I solved this problem on my own
Glad it helped!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.
Worst Case Complexity: O(2n).
If burningNode present as rightmost leave.
what is the time complexity of this approach?????
Why can't we use bfs here? I mean keep storing the next set of nodes in a queue with time. It's easy like this.
But for storing the parent node, we'll have to use hashmap don't we ??
here, we only need to find the farthest node from the node i, if we had to print the nodes burnt in order, then bfs would have been useful.
Intro 😍
Thanks!!!!!! 🤩🤩
Hope you like the video,
For better experience and precisely arranged videos sign up on nados.io
doing it own after solving k nodes
Hope you like the video.
For better experience and well organised content sign up on nados.io
Don't forget to follow us on Instagram instagram.com/pepcoding/
Blocknode return
We have to find out the longest path from current node to leaf node . Thats all
But if the given node is itself a leaf node then ?
halwa question after solving all nodes k distance away
lol
1 2 3 4 5 N 6 N N 7 8 N 9 N N N N N 10
target : 1
this test case faild on gfg. same code passed on pepcoding but not on gfg
Is it solved??
Geeks for geeks has buggy software. When I ran the same as custom input it showed correct answer
Try initializing the maxTime = 0 before calling the burningTree_ everytime. It will work.
It's because static global variable retains it's memory when tests are run in sequence. That's the reason same test will pass when run alone.
You can initialize maxTime=0 (at line 52 according to above code), before giving a call to burningTree_