Skip to content

Commit e139997

Browse files
authored
Update addTwoNumbers.md
1 parent e586a23 commit e139997

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

leetcode/add-two-numbers/addTwoNumbers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Approach : Elementary Math
55
Algorithm
66

77
Just like how you would sum two numbers on a piece of paper,
8-
we begin by summing the least-significant digits, which is the head of l1 and l2. Since each digit is in the range of 0 \ldots 90…9, summing two digits may "overflow". For example 5 + 7 = 125+7=12. In this case, we set the current digit to 22 and bring over the carry = 1carry=1 to the next iteration. carrycarry must be either 00 or 11 because the largest possible sum of two digits (including the carry) is 9 + 9 + 1 = 199+9+1=19.
8+
we begin by summing the least-significant digits, which is the head of l1 and l2. Since each digit is in the range of 0 \ldots 90…9, summing two digits may "overflow". For example 5 + 7 = 12. In this case, we set the current digit to 2 and bring over the carry = 1 to the next iteration. carrycarry must be either 0 or 1 because the largest possible sum of two digits (including the carry) is 9 + 9 + 1 = 199+9+1=19.
99

1010
The pseudocode is as following:
1111

0 commit comments

Comments
 (0)