Add to Digit Array

Sometimes a large number is easier to store as a list of its digits instead of one regular value. Given a list num, where the digits are written from left to right, and an integer k, add k to that number. Return the result as a list of digits too.

Примеры

Ввод
[1, 2, 0, 0], 34
Вывод
[1, 2, 3, 4]
Ввод
[2, 7, 4], 181
Вывод
[4, 5, 5]
Ввод
[2, 1, 5], 806
Вывод
[1, 0, 2, 1]

Нужно реализовать

def add_to_array_form(num: list[int], k: int) -> list[int]:

Теги

arraymath
PostgreSQLv16

Šeit parādīsies koda izpildes rezultāts

Visible tests
1
Input
[1,2,0,0], 34
Expected[1,2,3,4]
2
Input
[2,7,4], 181
Expected[4,5,5]
3
Input
[2,1,5], 806
Expected[1,0,2,1]
4
Input
[0], 23
Expected[2,3]
5
Input
[9,9,9], 1
Expected[1,0,0,0]
6
Input
[1], 23
Expected[2,4]
Focus radio
Paused · SomaFM · Fluid