🚀

Thanksgiving Sale: Use Coupon Code THANKS25 to Get Extra 25% Off.

00DAYS
:
00HOURS
:
00MINUTES
:
00SECONDS

Leetcode Problem 2160. Minimum Sum of Four Digit Number After Splitting Digits

2160. Minimum Sum of Four Digit Number After Splitting Digits

Leetcode Solutions

Sorting Digits Approach

  1. Convert the integer num to a string to easily access individual digits.
  2. Split the string into its constituent digits.
  3. Sort the array of digits in ascending order.
  4. Form two new numbers by pairing the first and third smallest digits for the first number, and the second and fourth smallest digits for the second number.
  5. Convert the two new strings back to integers.
  6. Return the sum of the two new integers.
UML Thumbnail

Brute Force Permutations Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...