当前位置:网站首页>Sum of two leetcode numbers
Sum of two leetcode numbers
2022-06-11 14:14:00 【Daily study of bald girls】
LeetCode Sum of two numbers
LeetCode Day 4
subject : Given an array of integers nums And an integer target value target, Please find and as the target value in this array target the Two Integers , And return their array subscripts .
Suppose that each input corresponds to only one answer . however , The same element in the array cannot be repeated in the answer . Answers can be returned in any order .
Example 1:
Input :nums = [2,7,11,15], target = 9
Output :[0,1]
explain : because nums[0] + nums[1] == 9 , return [0, 1] .
Topic link :https://leetcode-cn.com/problems/two-sum/
Violent problem solving
/** * Note: The returned array must be malloced, assume caller calls free(). */
int* twoSum(int* nums, int numsSize, int target, int* returnSize)
{
int i,j;
for(i=0;i<numsSize;i++)
{
for(j=i+1;j<numsSize;j++)
{
if(nums[i]+nums[j]==target)
{
int *result=(int*)malloc(sizeof(int)*2);
result[0]=i;
result[1]=j;
*returnSize=2;
return result;
}
}
}
return 0;
}

边栏推荐
- SQL must know and know
- gensim.models word2vec 参数
- couldn‘t upgrade db schema: insert into ACT_GE_PROPERTY values (‘common.sche[已解决]
- 二十八-三维点云实时和离线生成二维栅格、三维栅格地图
- Current situation and future development trend of global and Chinese transcranial magnetic stimulation coil Market from 2022 to 2028
- Question bank and answers for 2022 tool fitter (intermediate) operation certificate examination
- 非常值得學習的調度開源庫推薦
- Three level classification display
- Work summary: it took a long time to write SQL because of Cartesian product problem (Cartesian product summary attached)
- Stochastic dynamic economic dispatching model of wind power (realized by matlab code)
猜你喜欢

My struggle: my years in foreign enterprises (1)

cadence SPB17.4 - allegro - allegro_free_viewer

Recommended open source scheduling libraries worth learning

阿里一面,谈谈策略模式在项目中的使用

cadence SPB17.4 - group operation(add to group, view group list, delete group)

Question bank and answers of the latest national fire-fighting facility operators (primary fire-fighting facility operators) in 2022

可变参表达式

基于Qt开发实现的任务管理器

Easyexcel configuration and Application
Explanation of waitgroup usage in go language learning
随机推荐
[Clickhouse column] user initialization of new library role
tp6基于whoops的异常接管(漂亮的界面)
Just after the college entrance examination, I was confused and didn't know what to do? Tell me what I think
Private collection project practice sharing [Yugong series] February 2022 wechat applet -app Other properties of JSON configuration properties
In depth research and analysis report on ready to eat meat market for vacuum low temperature cooking in the world and China
Recommended open source scheduling libraries worth learning
Interview to build an aircraft carrier, screw on the job, pay
XXVIII - 3D point cloud real-time and offline generation of 2D grid and 3D grid map
Leetcode 1968. 构造元素不等于两相邻元素平均值的数组(可以,终于解决)
[issue 268] accidentally submit the test code to the production environment. I will teach you six ways to solve it in seconds!
Question bank and answers for 2022 tool fitter (intermediate) operation certificate examination
Current situation and future development trend of global and Chinese metalworking fluid market from 2022 to 2028
How to manage the server to make the website stable and smooth
Question bank and answers for 2022 tool fitter (intermediate) operation certificate examination
基于Qt开发实现的任务管理器
The application of machine learning in database cardinality estimation
In depth research and analysis report on global and Chinese plant extract products market
Extracting storage is the best memory method
In depth research and analysis report on global and Chinese liquid malt extract products market
Zhu Ping: in the post epidemic era, medical beauty operations should not only be distracted, but also reverse the routine