We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I have not solved the question, but from what I undestood - she always go on the right path and you have to tell the number of points where she had multiple choices to chose a path from.
For e.g. If the path is like A-->B and B-->C and B-->D
and A-->B-->C is the right path, then at B she had two choices and she would use her wand.
One option could be using shortest path algorithm to find out the shortest (which is also the only path) possible path and in that path you have to find number of points where there were multiple choices of path selection.
I would also say that a simple DFS will also solve the question (given there is only one unique path - which makes it tree and not a graph).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Count Luck
You are viewing a single comment's thread. Return to all comments →
I have not solved the question, but from what I undestood - she always go on the right path and you have to tell the number of points where she had multiple choices to chose a path from.
For e.g. If the path is like A-->B and B-->C and B-->D
and A-->B-->C is the right path, then at B she had two choices and she would use her wand.
One option could be using shortest path algorithm to find out the shortest (which is also the only path) possible path and in that path you have to find number of points where there were multiple choices of path selection.
I would also say that a simple DFS will also solve the question (given there is only one unique path - which makes it tree and not a graph).