Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6564 |

@blackshadows | 6400 |

@mb1973 | 5785 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4639 |

@sanjay05 | 3762 |

@mantu_singh | 3712 |

@gfgaccount | 3627 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@yaswanthero123 | 625 |

@vikash619 | 611 |

@venkat11803610 | 501 |

@roshan13ar | 396 |

@DevangSingh | 379 |

@ravi11815721 | 312 |

@hrishipangavhane | 286 |

@aryanjain85297 | 280 |

@kommaraju11806903 | 277 |

@infosumitraut | 272 |

@ankitsharma5422 | 256 |

Complete Leaderboard |

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.

**Example 1:**

**Input:**
N = 6
arr[] = {6, 8, 4, 5, 2, 3}
**Output:**
604
**Explanation:**
The minimum sum is formed by numbers
358 and 246

**Example 2:**

**Input:**
N = 5
arr[] = {5, 3, 0, 7, 4}
**Output:**
82
**Explanation:**
The minimum sum is formed by numbers
35 and 047

**Your Task:**

You **don't** have to print anything, printing is done by the driver code itself. Your task is to complete the function **minSum()** which takes the array **A[]** and its size **N**** **as inputs and returns the required sum.

**Expected Time Complexity: **O(N. log(N))

**Expected Auxiliary Space: **O(1)

**Constraints:**

1 ≤ N ≤ 35

0 ≤ A[] ≤ 9

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Min sum formed by digits

...