Ctrl K

Smallest Sum From Splitting the Digits

Easy
You are given a positive integer number. Distribute all of its digits between two non-negative integers: every digit of number must go into exactly one of them (as many times as it occurs), and the digits inside each integer may be arranged in any order. Leading zeros are allowed. Return the smallest possible sum of the two integers.
Example 1
number=5132 → 38

For example 13 and 25, which add up to 38. Nothing smaller is possible.

Example 2
number=900 → 9

The numbers 0 and 09 = 9 use the digits 9, 0, 0, for a sum of 9.

Example 3
number=73 → 10
Constraints
  • 10 ≤ number ≤ 10¹⁵
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsTriangle From Sticks EasyTwo Numbers From Four Digits EasyUp or Down for Every Post MediumRound Prices to a Total MediumSparse Ones in a Grid Hard
loading Python…
Input
number=5132
Expected
38

Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.