LeetCode solutions

2650. Split With Minimum Sum

My accepted Python solution to LeetCode problem 2650, Split With Minimum Sum, running in 3ms.

  • Difficulty: Easy
  • Python
  • Runtime 3ms
  • Memory 17.5MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 3ms, memory 17.5MB, accepted 2025-12-30.

python
class Solution:
    def splitNum(self, num: int) -> int:
        # Sort digits in ascending order
        digits = sorted(str(num))
        
        # Alternate digits between two numbers to minimize sum
        num1 = ""
        num2 = ""
        
        for i, d in enumerate(digits):
            if i % 2 == 0:
                num1 += d
            else:
                num2 += d
        
        return int(num1 or "0") + int(num2 or "0")

Source