Can someone make an editorial for the last 3 problems Please!
The last 3 questions are standard one:
- 3rd is just mutisource BFS.
- 4th is finding LCA using Binary lifting. Practice problem
- 5th one is finding the diameter of a tree.
Thanks !
Just store at each node the sum from root assume root as 1 to this node lets say it x.
this can be done easily as only one path exist between root and x. Now you have sum from 1 to x . stored at x
Lets say a query comes to find sum between u and v. lets say the lowest common ancestor better known as LCA of the 2 nodes is x. then answer is sum[u]+sum[v]-sum[x] as see x occurs in both the paths of u and v from root 1.
Finding LCA can be done with Euler tour and segment trees in same time and space complexity !
when will results come?
This post was flagged by the community and is temporarily hidden.
433/500 couldn’t debug D. Still can’t find the bug. used binary lifting.
Can anyone help debug- UJ8QuW - Online C++0x Compiler & Debugging Tool - Ideone.com
This post was flagged by the community and is temporarily hidden.
This post was flagged by the community and is temporarily hidden.
This post was flagged by the community and is temporarily hidden.
This post was flagged by the community and is temporarily hidden.
This post was flagged by the community and is temporarily hidden.
Most of them solved all.
There’s an edge case when both nodes lie in same path
Nope there isn’t
Can anyone send in some source which explains calculating diameter of a graph.
I also solve all .