关键字:Linked List, Math
题目要求:
Medium You are given two linked lists representing two non-negative numbers. 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.
例子:
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
int* twoSum(int* nums, int numsSize, int target) {
int *a = (int *) malloc (sizeof(int)*2);
int i, j;
for(i = 0; i < numsSize; i++)
for(j = i + 1; j < numsSize; j++)
if(nums[j] == target - nums[i])
{
a[0] = i;
a[1] = j;
return a;
}
return 0;
}