Given n cities and distances of each city from a starting city, say K. A traveler has to travel these cities in increasing order of distance and in a lexicographically increasing order of city names. Find max number of cities he can travel with the given constraints
cities: Chennai, Bangalore, Visakhapatnam, Hyderabad, Mumbai
distances: 380, 200, 250, 750, 635
Ans: 3
Possibilities:
Bangalore -> Chennai -> Mumbai
Bangalore -> Chennai -> Hyderabad
Can anyone provide solution?