-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq_10122_Two_Sum.json
54 lines (54 loc) · 1.61 KB
/
q_10122_Two_Sum.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
"question": {
"qid": "q_10122",
"diff": 1,
"tags": ["Array", "Hash Table"],
"title": "Two Sum",
"prompt": [
"Given an array of integers {{ nums }} and an integer {{ target }}, return indices of the two numbers such that they add up to {{ target }}.",
"You may assume that each input would have exactly one solution, and you may not use the same element twice.",
"You can return the answer in any order."
],
"examples": [
{
"input": "[2,7,11,15]",
"output": "[0,1]",
"explanations": [
"Because nums[0] + nums[1] == 2 + 7 == 9, return [0, 1]."
]
},
{
"input": "[3,2,4]",
"output": "[1,2]",
"explanations": [
"Because nums[1] + nums[2] == 2 + 4 == 6, return [1, 2]."
]
},
{
"input": "[3,3]",
"output": "[0,1]",
"explanations": [
"Because nums[0] + nums[1] == 3 + 3 == 6, return [0, 1]."
]
}
],
"constraints": [
"2 <= nums.length <= 10^4",
"-10^9 <= nums[i] <= 10^9",
"-10^9 <= target <= 10^9",
"Only one valid answer exists."
],
"functionArguments": ["nums", "target"],
"hints": [
"Think of a way to store the indices of the elements you've seen so far in a data structure that allows for fast retrieval."
]
},
"testcases": [
{ "tid": "1", "input": [[2, 7, 11, 15], 9], "expected": [0, 1] },
{ "tid": "2", "input": [[3, 2, 4], 6], "expected": [1, 2] },
{ "tid": "3", "input": [[3, 3], 6], "expected": [0, 1] }
],
"submitted": 0,
"accepted": 0,
"questionLevel": 5
}