Question: Solve using java only... Kindly provide correct solution Objective In this problem, you need to find the maximum number of cities that Jeff can visit
Solve using java only...
Kindly provide correct solution
Objective
In this problem, you need to find the maximum number of cities that Jeff can visit on his way from West to East.
As Jeff travels from West to East, he has two rules:
He can only travel to cities in lexicographic order egJeff cannot travel from Berkeley to Albany nor can he travel from Cityto City
He can only travel to cities that are further from the West than the city he is currently at egif Jeff is at Berkeley, he cannot travel to cities that are closer to the West than Berkeley
Implementation
Implement the method MaxCitiescitiesdistanceswhich returns the maximum number of cities that Jeff can visit.
The first input argument, cities, is an array of strings representing the city names. For example:
TucsonAlbany 'Smith', 'Westford', 'Berkeley'
The second input argument, distances, is an array of integers representing the distances from the West point to the cities. Each distance is unique and between and inclusiveThe first distance in distances corresponds to the first city in cities and so onFor example:
Your MaxCities method should return an integer, which represents the maximum number of cities that Jeff can visit.
For the above example, the correct output would be In this case, Jeff is able to visit Berkeley then Tucson then Westford while still following his two rules.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
