Question: Akira is working on a data compression algorithm and has devised a unique method to convert a list of numbers into a key. The process
Akira is working on a data compression algorithm and has devised a unique method to convert a list of numbers into a key. The process involves two phases
Concatenating Phase: Initially, create tempKeys by concatenating every pair of consecutive numbers in the list. For example, if the original list is the
tempKeys would be consecutive number of list indicates &hdrd&thth&th
Adding Phase: Next, add every two consecutive numbers in the tempKeys to obtain the keys. For example, for the tempKeys the resulting keys would be
These two phases are applied successively until a single key is derived. It's important to note that Akira will obtain a single key only when there is a single element leht in the
list
Help Akira by creating a program that takes a list of numbers as input and identifies the resulting key as output.
Read the input from STDIN and write the output to STDOUT. You should not write arbitrary strings while reading the input and while printing as these contribute to the
standard output.
Constraints:
i N N
Input format:
The first line of input should consist of an integer N
The second line of input should consist of N integers, each separated by a single white space.
Output format:
The only line of output should display the resulting number which will be the key of the compression algorithm.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
