Challenge 4: Trace the Complete Path of a Journey
Test your knowledge on hash table traversal with this coding exercise!
We'll cover the following
Problem statement
You have to implement the tracePath(Dictionary<string, string> map)
function, which will take in an array of source-destination pairs and return the correct sequence of the whole journey from the first city to the last.
Input
This is a Dictionary
of type <string, string>
containing string pairs of source-destination cities.
Output
It is a string of source-destination pairs in the correct order.
Sample input
map = {
"NewYork": "Chicago",
"Boston": "Texas",
"Missouri": "NewYork",
"Texas": "Missouri"
}
key: value
Sample output
Boston->Texas, Texas->Missouri, Missouri->NewYork, NewYork->Chicago
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.