leetcode2sumc-LeetCode:力扣笔记

时间:2021-07-06 17:44:43
【文件属性】:
文件名称:leetcode2sumc-LeetCode:力扣笔记
文件大小:15KB
文件格式:ZIP
更新时间:2021-07-06 17:44:43
系统开源 leetcode 2 和 c 力码 LeetCode /* No.1 [Two Sum] 给定一个整数数组,返回两个数字的索引,使它们相加为特定目标。 您可以假设每个输入都只有一个解决方案,并且您不能两次使用相同的元素。 例子: 给定 nums = [2, 7, 11, 15], target = 9, 因为 nums[0] + nums[1] = 2 + 7 = 9,返回 [0, 1]。 / C: 粗暴解决。执行用时:104 ms。 int twoSum(int* nums, int numsSize, int target) { int i,j; int* a = (int*)malloc(2*sizeof(int)); for(i=0;i<(numsSize-1);i++) { for(j=i+1;d<numsSize;j++) { if((nums[i]+nums[j])==target) { a[0]=i;a[1]=j;} } } return a;
【文件预览】:
LeetCode-master
----danche_backend()
--------package.json(300B)
--------readme.md(357B)
--------yarn.lock(21KB)
----.gitignore(2KB)
----875()
--------875.js(999B)
--------readme.md(351B)
--------go()
----README.md(633B)
----509.fibonacciNumber()
--------readme.md(75B)
--------509.js(330B)

网友评论