City staying problem.
There are two cities, City A and City B. Every day it costs adifferent amount to stay in either city. For instance, city A costs{a1, a2, … an} to stay for days 1, 2, .., n. and city B costs{b1, b2, ,,, , bn} to stay for days 1, 2, …, n. In addition, ittakes a constant cost c to travel from city A to city B, and viceversa.
Describe an O(n) algorithm in that gives the least cost to stayfor n days.
For example, lets stay n = 3; we are staying for 3 days. Wecould choose to stay
PayPal Gateway not configured
PayPal Gateway not configured