Question: COURSE: PYTHON QUESTION: Write following program code in Python Programming Language also attach output of running program. NOTE: Please solve as soon as possible and

COURSE: PYTHON

QUESTION:

Write following program code in "Python Programming Language" also attach output of running program.

NOTE: Please solve as soon as possible and i will give you thumbs up.

You are playing a game of hopscotch with these rules: The plot consists of a row of n squares, each with a number on it. These numbers are a,...,an, where a, > 0 is the number on the i-th square. You start at square 1 and with each jump you move either two or three squares forward from your current location: that is, from square i you can jump to square i + 2 or square i +3. You add up the numbers on the squares you jump through, and the person with the largest sum wins. What is the largest sum you can get? Design an O(n) algorithm for this problem.

For example, for input 1, 5, 2, 3, 6, 1,8, you can jump 1,-,2,-,6,-,8, with total sum 17, which is the largest possible sum. For input 1, 5, 2, 6, 3, 8, 1, the largest sum is 15 (jump sequence 1,-,-,6,-,8,-).

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 Databases Questions!