diff --git a/0001-Two-Sum/Article/0001-Two-Sum.md b/0001-Two-Sum/Article/0001-Two-Sum.md index be84999be02ef875f51cf91577aece879c84633a..95e8591c02aa814074b7d52505442d05153d8a77 100644 --- a/0001-Two-Sum/Article/0001-Two-Sum.md +++ b/0001-Two-Sum/Article/0001-Two-Sum.md @@ -37,7 +37,7 @@ ![](../Animation/Animation.gif) ### 代码实现 - +#### C++ ``` // 1. Two Sum // https://leetcode.com/problems/two-sum/description/ @@ -62,9 +62,87 @@ public: }; ``` - - - - +#### C +```c +// 1. Two Sum +// https://leetcode.com/problems/two-sum/description/ +// 时间复杂度:O(n) +// 空间复杂度:O(n) +/** + * Note: The returned array must be malloced, assume caller calls free(). + */ +int* twoSum(int* nums, int numsSize, int target, int* returnSize){ + int *ans=(int *)malloc(2 * sizeof(int)); + int i,j; + bool flag=false; + for(i=0;i