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://www.hxwzsj.com/article/jidihc.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 成都网站设计 网站建设方案 成都网站制作 网站建设公司 成都企业网站建设 网站制作报价 网站建设 成都网站设计制作公司 网站制作 成都网站建设 成都网站建设 成都网站制作 重庆手机网站建设 成都网站建设 成都网站制作 攀枝花网站设计 泸州网站建设 成都网站制作 成都网站建设公司 阿坝网站设计 重庆外贸网站建设 商城网站建设