Question: write a java method to return maximum score of the following game A few years ago, 2048 was a popular game to download and play

write a java method to return maximum score of the following game write a java method to return maximum score of the following game

A few years ago, 2048 was a popular game to download and play on the smartphone. You don't need to know anything about 2048, but here is a different game called 248. In 248, the game starts with a sequence of N integers where N is between 2 and 248 (inclusive) and each integer in the sequence is between 1 and 40 (inclusive). To play the game, the player must select two adjacent integers with equal values and replace them with a single integer of value one greater. For example, two adjacent 3's can be replaced with a 4. After repeatedly doing combination operations there will eventually be no more equal adjacent numbers in the sequence and the game is then done. The score at the end of a game is whatever number is largest in the final sequence. Write a program to find the largest possible score. Input The input will be N+1 integers separated by whitespace. The first integer gives the value of N, the number of integers in the sequence. The following N integers give the sequence of the N integers at the beginning of the game. Output A single integer the largest possible number remaining in the sequence after any sequence of legal com- bination operations. Sample Input Sample Output 5 4

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!