Skip to content
LC-2578 Easy LeetCode

2578. Split With Minimum Sum

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 72% Topics: Math, Greedy, Sorting
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(mlogm), m = O(logn)
# Space: O(m)

# sort, greedy
class Solution(object):
    def splitNum(self, num):
        """
        :type num: int
        :rtype: int
        """
        sorted_num = "".join(sorted(str(num)))
        return int(sorted_num[::2])+int(sorted_num[1::2])

Solution from kamyu104/LeetCode-Solutions · MIT