Geeksforgeeks

Timer is Running

Associated Course(s):
Geeks Classes
Geeks Classes- Algorithms

Given an array of digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array. All digits of given array must be used to form the two numbers.

**Input:**

The first line of input contains an integer T denoting the number of test cases.** **Then T test cases follow. First line of each test case contains an integer N denoting the size of the array. Next line of each test contains N space seperated integers denoting the elements of the array.

**Output:**

For each test case output a single line containing the required sum.

**Constraints:**

1<=T<=100

1<=N<=50

**Example:**

**Input**

2

6

6 8 4 5 2 3

5

5 3 0 7 4

**Output**

604

82

**Explanation:**

Test Case 1-

```
The minimum sum is formed by numbers
358 and 246
```

Test Case 2 -

```
The minimum sum is formed by numbers
35 and 047
```

Author: harshitsidhwa

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.

jainshubham52535 | 529 |

Pathak1899 | 436 |

yashdip123 | 380 |

kirtidee18 | 377 |

jots62 | 351 |

kirtidee18 | 1057 |

ykaushik | 752 |

aggarwalvatsal5 | 741 |

harbilassingh | 576 |

pmr_3689 | 570 |

blackshadows | 5456 |

Ibrahim Nash | 5450 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4827 |

Login to report an issue on this page.