Company: Barclays
Difficulty: medium
Magical Route Optimization Programming Language: Java A state consists of N cities numbered from 0 to N-1. All the roads in the state are bidirectional. Each city is connected to another city by one direct road only. A magician travels to these cities to perform shows. He knows a magic spell that can completely eliminate the distance between any two directly connected cities. But he must be very careful because this magic spell can be performed only K number of times. Write an algorithm to find the length of the shortest route between two given cities after performing the magic spell K number of times. The output is -1 if no path exists. Input Format The first line of the input consists of an integer - numCities , representing the number of cities (N). The second line consists of an integer - cityA , representing the city A. The third line consists of an integer - cityB , representing the city B. The fourth line consists of an integer - numMagic , representing the number of times the m