Leetcode 1. Two Sum with C
来源:互联网 发布:5118的子域名查询工具 编辑:程序博客网 时间:2024/06/01 07:22
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
Example:
Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1].
/** * Note: The returned array must be malloced, assume caller calls free(). */int* twoSum(int* nums, int numsSize, int target) { int reset_num = 0; int *result = (int*)malloc(sizeof(int)*2); int start = 0; int i = 0; while(start != numsSize) { reset_num = target - nums[start++]; for (i = start; i != numsSize; i++) { if (nums[i] == reset_num) { result[0] = start -1; result[1] = i; return result; } } } return NULL;}
0 0
- Leetcode 1. Two Sum with C
- LeetCode 1. Two Sum (C++)
- 【LeetCode with Python】 Two Sum
- LeetCode: 1. Two Sum【C 解题】
- 【Leetcode】【Python】【C++】1. Two Sum实现
- 【leetcode】1. Two Sum(Python & C++)
- LeetCode 1. Two Sum(c语言实现)
- LeetCode 1. Two Sum java solution with HashMap
- [C++]LeetCode: 14 Two Sum
- Leetcode[1] Two Sum (c++)
- LeetCode::Two Sum C语言
- [c++] LeetCode Two Sum问题
- [LeetCode#1][C]Two Sum
- 【LeetCode-1】 Two Sum(C++)
- LeetCode Two Sum(C/JS)
- LeetCode::Two Sum C语言
- Leetcode c语言-Two Sum
- LeetCode 1. Two Sum
- 关于Linux中创建软连接ln -s出现红色闪烁文件名
- Android scrollTo() scrollBy() Scroller讲解及应用
- Android动画实现多个ImageView绕着一个ImageVIew转圈
- iOS 开发 公司开发者账号,在多台Mac上合作开发,共用一个账号和证书--图文详解
- C#: 星座星盘计算算法
- Leetcode 1. Two Sum with C
- A1028. 选择计算
- bat-2
- android在手机桌面弹出一个提醒activity,finish掉后。从任务管理器进去还是这个提醒activity
- 在安卓DDMS中找相册文件夹传一张图片
- nil Nil NSnull sok svk
- SAPUI5 (07) - MVC文件的名称和位置
- 存储过程
- java根据IP获取用户所在地