Add Two Numbers
This commit is contained in:
31
include/s2_add_two_numbers.hpp
Normal file
31
include/s2_add_two_numbers.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef S2_ADD_TWO_NUMBERS_HPP
|
||||
#define S2_ADD_TWO_NUMBERS_HPP
|
||||
|
||||
struct ListNode {
|
||||
int val;
|
||||
ListNode* next;
|
||||
ListNode() : val(0), next(nullptr) {}
|
||||
ListNode(int x) : val(x), next(nullptr) {}
|
||||
ListNode(int x, ListNode* next) : val(x), next(next) {}
|
||||
};
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
/**
|
||||
* @brief Add Two Numbers
|
||||
*
|
||||
* 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 contains a single digit. Add the two numbers and return the sum as a
|
||||
* linked list.
|
||||
*
|
||||
* You may assume the two numbers do not contain any leading zero, except the
|
||||
* number 0 itself.
|
||||
*
|
||||
* @param l1 the first linked list
|
||||
* @param l2 the second linked list
|
||||
*/
|
||||
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2);
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user