Company: PayPal SWE Intern_30oct
Difficulty: medium
Profitable Journey Problem Description A traveler passes through a row of cities represented as an array of integers, where each integer is the money spent (if negative) or earned (if positive) while staying in that city for a day. The trip begins at city 0 and must end at city (n-1). From any city, the traveler may step to an adjacent city, or jump to a city that is p positions away, where p is any prime number ending in the digit 3. Work out the largest total amount of money the traveler can end the trip with. Consider cities = [10, 200, -200, -50, 100, -80] The best possible route yields a total of 100. The traveler begins in city 0, steps to city 1 to gain 100, steps to city 2 to reach 100+200 = 300, then jumps to city 2+3 = 5 to reach 300 + (-50) = 150, and finally steps to city 6 to reach 150 + (-80) = 100. The only jump distance available here is 3, since it is the sole prime ending in the digit 3 that fits within the size of this array, so moves are restricted to (i+p) or (i-p)