Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ce3bdee

Browse files
committed
Merge branch 'master' of github.com:Neodelf/leetcode
2 parents 537ba5a + 64099fa commit ce3bdee

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

‎2/README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### 2. Add Two Numbers
2+
3+
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
4+
5+
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
6+
7+
```
8+
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
9+
Output: 7 -> 0 -> 8
10+
```

‎2/add_two_numbers.rb‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111
# @param {ListNode} l2
1212
# @return {ListNode}
1313
def add_two_numbers(l1, l2)
14-
ll_common = ListNode.new(nil)
15-
ll = ll_common
14+
ln_result = ListNode.new(nil)
15+
ln = ln_result
1616
next_is_present = true
1717
while next_is_present
1818
next_is_present = l1&.next || l2&.next
19-
ll_val = l1&.val.to_i + l2&.val.to_i + ll&.val.to_i
20-
int = ll_val/10
19+
ln_val = l1&.val.to_i + l2&.val.to_i + ln&.val.to_i
20+
int = ln_val/10
2121

22-
ll.val = int > 0 ? ll_val - 10 : ll_val
23-
ll.next = ListNode.new(int) if next_is_present || int > 0
22+
ln.val = int > 0 ? ln_val - 10 : ln_val
23+
ln.next = ListNode.new(int) if next_is_present || int > 0
2424

2525
l1 = l1.next if l1
2626
l2 = l2.next if l2
27-
ll = ll.next
27+
ln = ln.next
2828
end
29-
ll_common
29+
ln_result
3030
end

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# leetcode-ruby-solutions
2+
Solutions of the issues from leetcode.com
3+
4+
5+
#### Tasks:
6+
* Change structure in order to repository has one README file with list of all solutions

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /