← All problemsSign in

5 Cities

Suman lives in AlgoWorld. There are only 5 cities in AlgoWorld. He has to start from the first city and travel precisely n kilometers. There are exactly 10 directed ways between the cities, two from each city. Distance from city x to city y is denoted by d(x,y) . Can you help Suman find a way to do this? If there are multiple solutions, the route should consist of the smallest number of nodes. A

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start