LeetCode001TwoSumC语言

1.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].

UPDATE (2016/2/13):
The return format had been changed to zero-based indices. Please read the above updated description carefully.

Subscribe to see which companies asked this questio
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* twoSum(int* nums, int numsSize, int target) {
    int i,j;
    int *a = (int *)malloc(sizeof(int) * 2);
    for(i=0;i

LeetCode第一题!!!!没想到两层循环就解决了,想想还有点激动。看了网上才知道这样

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名与空间、雅安服务器托管、营销软件、网站建设、扶余网站维护、网站推广。

时间复杂度O(N*2)。

好像快点的话还可以hash表?

有机会再说吧[%>_<%]


文章题目:LeetCode001TwoSumC语言
分享地址:http://bzwzjz.com/article/jidihc.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 外贸网站建设 手机网站制作设计 企业网站设计 成都网站建设 成都营销网站建设 古蔺网站建设 成都网站建设推广 高端品牌网站建设 网站建设费用 网站建设方案 成都网站建设 营销型网站建设 成都网站制作 成都网站建设 网站制作 成都网站制作 网站设计 成都企业网站建设公司 成都营销网站制作 成都网站设计 成都响应式网站建设 达州网站设计