Question: write a program in c++ by using arrays and loops . A traveller wants to travel from point A to point B and he has

   

write a program in c++ by using arrays and loops .

A traveller wants to travel from point A to point B and he has two path options (path1, path2). Find a new path with minimum cost from the beginning of any path to the end of any of the two paths. We can switch from one path to another path only at the common elements. The path costs are given: path1= [2,3,7,10,12] path2=[1,5,7,8] Output: 20 Explanation: first path will be: 2+3+7+10+12 = 34 Second path will be: 2+3+7+8= 20 As second path is smallest so output will be 20.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!