Minimum Sum of Four Digit Number After Splitting Digits

You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leading zeros are allowed in new1 and new2, and all the digits found in num must be used.

Return the minimum possible sum of new1 and new2.

Example 1
Inputnum = 2932
Output52
The minimum sum can be obtained by the pair [29, 23]: 29 + 23 = 52.
Example 2
Inputnum = 4009
Output13
The minimum sum can be obtained by the pair [4, 9]: 4 + 9 = 13.

Constraints

  • 1000 <= num <= 9999

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate