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 actually don't have to cater for that since I used BFS rather than DFS (it is a queue challenge...) so any cell already visited will have it's lowest possible value. In other words if I previously visited a cell it's because it's already nearer via it's previous route than it can possibly be now.
I personally set the distance to numeric_limits::max() for all cells. Any cell with a different value has been visited.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Castle on the Grid
You are viewing a single comment's thread. Return to all comments →
I actually don't have to cater for that since I used BFS rather than DFS (it is a queue challenge...) so any cell already visited will have it's lowest possible value. In other words if I previously visited a cell it's because it's already nearer via it's previous route than it can possibly be now.
I personally set the distance to numeric_limits::max() for all cells. Any cell with a different value has been visited.