Skip to content

Commit 6b56e17

Browse files
committed
The Leetcode C Project.
1 parent 3ff6ee7 commit 6b56e17

File tree

5 files changed

+151
-0
lines changed

5 files changed

+151
-0
lines changed

C/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
*.class
3+
4+
# idea
5+
.idea/
6+
7+
cmake-build-debug/
8+
9+
# Mobile Tools for Java (J2ME)
10+
.mtj.tmp/
11+
12+
# Package Files #
13+
*.jar
14+
*.war
15+
*.ear
16+
17+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
18+
hs_err_pid*
19+
20+
*.idea
21+
22+
*.iml
23+
24+

C/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(C C)
3+
4+
set(CMAKE_C_STANDARD 99)
5+
6+
add_executable(C main.c)

C/leetcode/editor/cn/1_two-sum.c

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。
2+
//
3+
// 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。
4+
//
5+
// 你可以按任意顺序返回答案。
6+
//
7+
//
8+
//
9+
// 示例 1:
10+
//
11+
//
12+
//输入:nums = [2,7,11,15], target = 9
13+
//输出:[0,1]
14+
//解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。
15+
//
16+
//
17+
// 示例 2:
18+
//
19+
//
20+
//输入:nums = [3,2,4], target = 6
21+
//输出:[1,2]
22+
//
23+
//
24+
// 示例 3:
25+
//
26+
//
27+
//输入:nums = [3,3], target = 6
28+
//输出:[0,1]
29+
//
30+
//
31+
//
32+
//
33+
// 提示:
34+
//
35+
//
36+
// 2 <= nums.length <= 10⁴
37+
// -10⁹ <= nums[i] <= 10⁹
38+
// -10⁹ <= target <= 10⁹
39+
// 只会存在一个有效答案
40+
//
41+
//
42+
// 进阶:你可以想出一个时间复杂度小于 O(n²) 的算法吗?
43+
// Related Topics 数组 哈希表 👍 14092 👎 0
44+
45+
46+
// 2022-04-10 09:48:51
47+
// By Long Luo
48+
49+
#include<bits/stdc++.h>
50+
51+
using namespace std;
52+
53+
//leetcode submit region begin(Prohibit modification and deletion)
54+
55+
56+
/**
57+
* Note: The returned array must be malloced, assume caller calls free().
58+
*/
59+
int* twoSum(int* nums, int numsSize, int target, int* returnSize){
60+
61+
}
62+
//leetcode submit region end(Prohibit modification and deletion)
63+
64+
65+
int main()
66+
{
67+
Solution s;
68+
vector<int> data{7, 1, 5, 3, 6, 4};
69+
//vector<int> ans = s.twoSum(data,11);
70+
//cout << ans[0]<<ans[1]<<endl;
71+
cout<<"Hello LeetCode"<<endl;
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<p>给定一个整数数组 <code>nums</code>&nbsp;和一个整数目标值 <code>target</code>,请你在该数组中找出 <strong>和为目标值 </strong><em><code>target</code></em>&nbsp; 的那&nbsp;<strong>两个</strong>&nbsp;整数,并返回它们的数组下标。</p>
2+
3+
<p>你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。</p>
4+
5+
<p>你可以按任意顺序返回答案。</p>
6+
7+
<p>&nbsp;</p>
8+
9+
<p><strong>示例 1:</strong></p>
10+
11+
<pre>
12+
<strong>输入:</strong>nums = [2,7,11,15], target = 9
13+
<strong>输出:</strong>[0,1]
14+
<strong>解释:</strong>因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。
15+
</pre>
16+
17+
<p><strong>示例 2:</strong></p>
18+
19+
<pre>
20+
<strong>输入:</strong>nums = [3,2,4], target = 6
21+
<strong>输出:</strong>[1,2]
22+
</pre>
23+
24+
<p><strong>示例 3:</strong></p>
25+
26+
<pre>
27+
<strong>输入:</strong>nums = [3,3], target = 6
28+
<strong>输出:</strong>[0,1]
29+
</pre>
30+
31+
<p>&nbsp;</p>
32+
33+
<p><strong>提示:</strong></p>
34+
35+
<ul>
36+
<li><code>2 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
37+
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
38+
<li><code>-10<sup>9</sup> &lt;= target &lt;= 10<sup>9</sup></code></li>
39+
<li><strong>只会存在一个有效答案</strong></li>
40+
</ul>
41+
42+
<p><strong>进阶:</strong>你可以想出一个时间复杂度小于 <code>O(n<sup>2</sup>)</code> 的算法吗?</p>
43+
<div><div>Related Topics</div><div><li>数组</li><li>哈希表</li></div></div><br><div><li>👍 14092</li><li>👎 0</li></div>

C/main.c

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
int main() {
4+
printf("Hello, World!\n");
5+
return 0;
6+
}

0 commit comments

Comments
 (0)