Merge Array Elements and Find Smallest

Company: Greener_16nov

Difficulty: easy

Problem Statement

Merge Array Elements and Find Smallest You are given an array arr = (x1, x2, x3, ..., xN) of N non-negative integers. Walk through the array from left to right and merge it in consecutive pairs: merge(x1, x2) , merge(x3, x4) , merge(x5, x6) , and so on. Merging two numbers means writing their decimal representations one after the other and reading the result back as a number: merge(33, 52) is 3352 , and merge(1, 0) is 10 . If N is odd, the final element has no partner; it is left exactly as it is and counts as a merged element on its own. Print the smallest of the merged elements. Read the input from STDIN and print the output to STDOUT. Do not write any other text while reading the input or while printing, as it becomes part of the output. Input Format The first line of input consists of a single integer N . The second line consists of N integers, each separated by a single whitespace. Output Format A single line holding the smallest number among the merged elements. Constraints 1 &lt