Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer.
You may assume the integer do not contain any leading zero, except the number 0 itself.
The digits are stored such that the most significant digit is at the head of the list.
Example:
解法1:
考察linkedlist基本功的一道题,先reverse再加1再reverse
C++
Java
解法2: Recursion
此题也可以用递归的办法做。因为递归会自然的把list倒过来处理。
|
|