digits: each node holds one digit, and the most significant digit is at the head.
Add one to the number and return the head of a list that describes the result in the same form. If the number gets longer (as after 999), a new node must appear at the front.digits=list_node([4, 0, 7]) → [4, 0, 8]
407 + 1 = 408: only the last digit changes.
digits=list_node([2, 9, 9]) → [3, 0, 0]
299 + 1 = 300: both nines turn into zeros and the carry bumps the 2.
digits=list_node([9]) → [1, 0]
9 + 1 = 10: a new node appears at the front.
Node.val ≤ 9digits=list_node([4, 0, 7])
[4, 0, 8]
Run checks the first 3 tests in your browser. Submit checks all 72 tests on the server, hidden ones included.