当前位置:网站首页>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;
}

边栏推荐
- 非常值得学习的调度开源库推荐
- 阿里一面,谈谈策略模式在项目中的使用
- Leetcode 1963. 使字符串平衡的最小交换次数(学习)
- I have something to say about final, finally and finalize
- 【Try to Hack】URL
- .NET C#基础(6):命名空间 - 有名字的作用域
- cadence SPB17.4 - allegro - allegro_ free_ viewer
- MySQL数据库创建索引的方法和好处
- Single table query of SQL data query
- Easyexcel configuration and Application
猜你喜欢

.NET C#基础(6):命名空间 - 有名字的作用域

Top 10 bone conduction earphones in the list, and five easy-to-use bone conduction earphones are recommended

Online "comment explicit" function, TME's wave point music cultivates music "private plots"

【Try to Hack】URL

MySQL create table error 1067 - invalid default value for 'update_ time‘

Leetcode 1968. 构造元素不等于两相邻元素平均值的数组(可以,终于解决)

Leetcode 1968. Construct an array whose elements are not equal to the average value of two adjacent elements (yes, finally solved)

RS485(Modbus RTU)工业RFID读写器CK-FR03-A01与PLC三菱FX5U的通讯操作说明

How to quickly make the title and ending with one click?

强大的全文本搜索工具——AnyTXT Searcher
随机推荐
Code comparison tool, I use these six
cadence SPB17.4 - allegro - allegro_free_viewer
三级分类展示
Zhu Ping: in the post epidemic era, medical beauty operations should not only be distracted, but also reverse the routine
[signal processing] digital signal processing matlab design with GUI interface and report
airtest自动化测试
2022年甘肃省安全员B证考试题模拟考试题库及在线模拟考试
二十八-三维点云实时和离线生成二维栅格、三维栅格地图
CVPR 2022 | 神经辐射场几何编辑方法NeRF-Editing
Collapse expression
MySQL advanced statement
How to quickly compress the size of video?
Invalid bound statement (not found) error [resolved]
In depth research and analysis report on global and Chinese high purity molybdenum market
Redis uses 10 tips, please accept!
Check box select all or deselect all
基于FPGA的VGA协议实现
AGV robot RFID sensor ck-g06a and Siemens 1200plc Application Manual
VIM secondary replacement
In depth research and analysis report on global and Chinese sanitary safety product market