Question: Please write a full answer and give a good explanation. 16. The new swap-puzzle game Candy Swap Saga XIII involves n cute animals numbered from

 Please write a full answer and give a good explanation. 16.

Please write a full answer and give a good explanation.

16. The new swap-puzzle game Candy Swap Saga XIII involves n cute animals numbered from 1 to n. Each animal holds one of three types of candy: circus peanuts, Heath bars, and Cioccolateria Gardini chocolate truffles. You also have a candy in your hand; at the start of the game, you have a circus peanut. To earn points, you visit each of the animals in order from 1 to n. For each animal, you can either keep the candy in your hand or exchange it with the candy the animal is holding. If you swap your candy for another one point. candy of the same type, you earn MIC PROGRAMMING If you swap your candy for a candy of a different type, you lose one point. (Yes, your score can be negative.) If you visit an animal and decide not to swap candy, your score does not You must visit the animals in order, and once you visit an animal, you can Describe and analyze an efficient algorithm to compute your maximum change. never visit it again possible score. Your input is an array C[1..n], where C[i] is the type of candy that the ith animal is holding

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!