An alternative trick to solve many HLD problems using basic dfs

Thanx understood the idea behind it !!!

@hikarico Thanks. The choosing of value can also depend on the tree that has been given so we can choose the value depending on the tree also as mentioned in Upd1

In updates for adding nodes we can actually follow the same procedure as we are going to change only nodes with depth%1000=x and so if a new node is added it doesn’t make a difference to its ancestors(See my GPD solution).

For changing of values I am thinking of a solution and if I could get one I will update the blog.If someone else has an idea you could put it here and I will add it to the blog with your name/handle.