Self Driving startup in SF
Anonymous User
409

Given a starting point (call it garage). The car will traverse the map and it has to return back to the garage. Return all the vertices reachable in the multiple paths that the car takes.

example :
Input Graph is Directed, garage is 2 (starting point)

2-> {1,3}
3->{4}
4->{5}
5->{2,6}
6->{7}
7->{4}

return : { 2,3,4,5,6,7}
explaination :
There are two valid tours

  1. 2->3->4->5->2
  2. 2->3->4->5->6->7->4->5->2

The intersection of the valid tours = { 2,3,4,5,6,7}

Comments (1)