Leetcode_Two Sum
来源:互联网 发布:数据库管理发展三阶段 编辑:程序博客网 时间:2024/05/16 12:22
/** the first version
* Note: The returned array must be malloced, assume caller calls free(). */int* twoSum(int* nums, int numsSize, int target) { int i,j; int *pos; int flag = 0; pos = (int *) malloc(2*sizeof(int)); if(pos == NULL) { return NULL; } pos[0] = 0; pos[1] = 0; for (i = 0; (i < numsSize) && (flag == 0); ++i) { for(j = i + 1; (j < numsSize) && (flag == 0); ++ j) { if(nums[i] + nums[j] == target) { pos[0] = i; pos[1] = j; flag = 1; } } } return pos;
the test result of the first version
0 0
- leetcode_Two Sum
- Leetcode_Two Sum
- LeetCode_Two Sum
- LeetCode_Two Sum
- LeetCode_Two Sum
- LeetCode_Two Sum
- leetcode_two sum
- Leetcode_Two Sum
- leetcode_Two sum
- leetcode_Two Sum
- leetcode_two sum()
- Leetcode_Two Sum II
- leetcode_Two Sum II
- Leetcode_two-sum (c++ and python version)
- Sum
- sum
- sum
- Sum
- html(1)
- 怎样看待比自己强的人
- POJ 1043 What's In A Name? 已被翻译
- hdu1158(dp)
- CCF计算机软件能力认证模拟试题(c/c++)
- Leetcode_Two Sum
- 一个人
- zzu 10452: "分"数(控制数量的01背包)@
- 含继承在内的初始化过程 ——《Thinking in java》 读书笔记之一
- LeetCode 104 Maximum Depth of Binary Tree题解
- 欢迎使用CSDN-markdown编辑器
- 使用Geogebra和Tikz作图
- ImageLoader总结
- noip2016(tg)题解