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
+ }
0 commit comments