 Timer is Running

Maximum Integer Value
##### Submissions: 4131   Accuracy: 25.25%   Difficulty: Basic   Marks: 1

Given a string S of digits(0-9), your task is to find the maximum value that can be obtained from the string by putting either '*' or '+' operators in between the digits while traversing from left to right of the string and picking up a single digit at a time.

Input:
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contans one line of input denoting the string.

Output:
For each testcase, print the maximum value obtained.

Constraints:
1 <= T <= 100
1 <= |S|< = 20
0 <= Digits <= 9

Example:
Input:
2
01230
891

Output:
9
73

Explanation:
Testcase1: we have 01230. We traverse from left and pick zero. Now we encounter 1. We see if 0*1 gives maximum or 0+1. Now we have ans as 1. Now we traverse further. We encounter 2. Now 1*2 gives max or 1+2. Now we have ans 3. Now we traverse further. We encounter 3. We see if 3*3 gives max or 3+3. The ans is now 9. Now we traverse fiurther. We encounter 0, we see  if 9+0 gives max or 9*0. The ans is now 9. We've traversed whole string so we stop.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sahil Chhabra
Author: Sahil_Chhabra

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.