Programmazione competitivaFacile

Somma minima formata da cifre

Guida dettagliata e implementazione Python per il problema della "somma minima formata da cifre".

Dichiarazione del problema

Facile

Scrivi una funzione min_sum_digits(arr) che accetta un elenco di numeri interi a cifra singola arr (0-9) e restituisce la somma minima di due numeri formati utilizzando tutte le cifre dell'array.

Vincoli
  • 2 <= len(arr) <= 30
  • 0 <= arr[i] <= 9

Esempi

Example 1
Input
min_sum_digits([6, 8, 4, 5, 2, 3])
Output
604
Explanation

The minimum sum is obtained by forming the numbers 246 and 358: 246 + 358 = 604.

Example 2
Input
min_sum_digits([5, 3, 0, 7, 4])
Output
82
Explanation

The minimum sum is obtained by forming the numbers 35 and 47 (or 047): 35 + 47 = 82.

Need a Hint?
Prendi in considerazione l'utilizzo di strutture dati specifiche di Greedy come set o heap.
Edge Cases to Watch
  • Strutture di input vuote
  • Ingressi a elemento singolo
  • Grandi limiti numerici

Pronto a risolvere?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Apri nell'editor
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

Risorse Python consigliate

Espandi le tue conoscenze con tutorial interattivi, foglietti illustrativi e confronti di codici correlati.