题目描述:
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.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
样例:
1 | Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) |
题意:
给你两个表示非负数字的链表。数字以相反的顺序存储,其节点包含单个数字。将这两个数字相加并将其作为另外一个链表返回。
题解:
这道题其实就是一个暴力,时间的长短,主要就是看怎么一个写法,蚊子第一次的解法是这样的:
1 | /** |
Runtime:40ms Memory:19.2MB faster than 96.34%
康了一下网友的题解,大致都跟蚊子的一样,这里就不拖出来康了。