题解 | #链表相加(二)#
链表相加(二)
https://www.nowcoder.com/practice/c56f6c70fb3f4849bc56e33ff2a50b6b
我服了,题目不是说长度在10的6次方以内吗?怎么样例有个40位数!写了半天发现longlong都不够。。。
不过反转链表还是很重要的知识点:
ListNode* reverseList(ListNode* head){
ListNode* cur = head;
ListNode* node = nullptr;
while (cur) {
ListNode* tail = cur->next;
cur->next = node;
node = cur;
cur = tail;
}
return node;
}
查看4道真题和解析
