Minimum Sum of Four Digit Number After Splitting Digits

EasyMathGreedySorting

Solution

export function minimumSum(num: number): number {
  const [a, b, c, d] = [...num.toString()].map(Number).sort((a, b) => a - b);
  return 10 * (a + b) + c + d;
}