FunctionRacerProblemsRace

Multiply Number by a Digit

EasyLinked listsPython, JavaScript, TypeScript, Java, C++

The list holds the digits of a non-negative number, most significant digit first. Multiply that number by the single digit d (0 to 9) and return the digits of the product in the same format, with no leading zeros. A product of 0 is the single node 0. The list is passed in as head.

Linked lists appear in the tests as the list of their values, like [1,2,3]. Each node is a ListNode with .val and .next; the class is already defined for you.

Example 1

head [1,2,5]
d 4
returns [5,0,0]

125 * 4 = 500.

Example 2

head [9,9]
d 9
returns [8,9,1]

99 * 9 = 891.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Linked lists problems