Repository navigation
Expand file tree
/
Copy pathdsa_questions.json
More file actions
259 lines (259 loc) · 11.4 KB
/
Copy pathdsa_questions.json
File metadata and controls
259 lines (259 loc) · 11.4 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
{
"questions": [
{
"type": "CODING",
"order": 1,
"points": 10,
"prompt": "Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`.\n\nYou may assume that each input would have exactly one solution, and you may not use the same element twice.\n\nYou can return the answer in any order.\n\n**Input Format:**\nThe first line contains an integer `target`.\nThe second line contains an integer `n` representing the size of the array.\nThe third line contains `n` space-separated integers representing the array elements.\n\n**Output Format:**\nPrint two space-separated integers representing the indices of the two numbers that add up to the target. The indices should be sorted in ascending order.\n\n**Constraints:**\n- `2 <= n <= 10^4`\n- `-10^9 <= nums[i] <= 10^9`\n- `-10^9 <= target <= 10^9`\n- Only one valid answer exists.",
"starterCode": "// write your code here",
"testcases": [
{
"input": "9\n4\n2 7 11 15",
"expectedOutput": "0 1",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "6\n3\n3 2 4",
"expectedOutput": "1 2",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "6\n2\n3 3",
"expectedOutput": "0 1",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "0\n4\n0 4 3 0",
"expectedOutput": "0 3",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "-8\n5\n-1 -2 -3 -4 -5",
"expectedOutput": "2 4",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "100\n6\n10 20 30 40 50 60",
"expectedOutput": "3 5",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "20\n5\n5 10 15 25 30",
"expectedOutput": "0 2",
"isHidden": true,
"timeoutMs": 2000
}
]
},
{
"type": "CODING",
"order": 2,
"points": 10,
"prompt": "Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid.\n\nAn input string is valid if:\n1. Open brackets must be closed by the same type of brackets.\n2. Open brackets must be closed in the correct order.\n3. Every close bracket has a corresponding open bracket of the same type.\n\n**Input Format:**\nThe first line contains a single string `s`.\n\n**Output Format:**\nPrint `true` if the string is valid, and `false` otherwise.\n\n**Constraints:**\n- `1 <= s.length <= 10^4`\n- `s` consists of parentheses only `'()[]{}'`.",
"starterCode": "// write your code here",
"testcases": [
{
"input": "()",
"expectedOutput": "true",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "()[]{}",
"expectedOutput": "true",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "(]",
"expectedOutput": "false",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "([)]",
"expectedOutput": "false",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "{[]}",
"expectedOutput": "true",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "((",
"expectedOutput": "false",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "]",
"expectedOutput": "false",
"isHidden": true,
"timeoutMs": 2000
}
]
},
{
"type": "CODING",
"order": 3,
"points": 15,
"prompt": "Given a string `s`, find the length of the longest substring without repeating characters.\n\n**Input Format:**\nThe first line contains a single string `s`.\n\n**Output Format:**\nPrint a single integer representing the length of the longest substring without repeating characters.\n\n**Constraints:**\n- `0 <= s.length <= 5 * 10^4`\n- `s` consists of English letters, digits, symbols and spaces.",
"starterCode": "// write your code here",
"testcases": [
{
"input": "abcabcbb",
"expectedOutput": "3",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "bbbbb",
"expectedOutput": "1",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "pwwkew",
"expectedOutput": "3",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": " ",
"expectedOutput": "1",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "au",
"expectedOutput": "2",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "dvdf",
"expectedOutput": "3",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "tmmzuxt",
"expectedOutput": "5",
"isHidden": true,
"timeoutMs": 2000
}
]
},
{
"type": "CODING",
"order": 4,
"points": 15,
"prompt": "Evaluate the value of an arithmetic expression in Reverse Polish Notation.\n\nValid operators are `+`, `-`, `*`, and `/`. Each operand may be an integer or another expression.\n\nNote that division between two integers should truncate toward zero.\n\nIt is guaranteed that the given RPN expression is always valid. That means the expression would always evaluate to a result, and there will not be any division by zero operation.\n\n**Input Format:**\nThe first line contains an integer `n` representing the number of tokens.\nThe second line contains `n` space-separated strings representing the tokens in the RPN expression.\n\n**Output Format:**\nPrint a single integer representing the evaluated result.\n\n**Constraints:**\n- `1 <= n <= 10^4`\n- tokens[i] is either an operator: `\"+\"`, `\"-\"`, `\"*\"`, or `\"/\"`, or an integer in the range `[-200, 200]`.",
"starterCode": "// write your code here",
"testcases": [
{
"input": "5\n2 1 + 3 *",
"expectedOutput": "9",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "5\n4 13 5 / +",
"expectedOutput": "6",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "13\n10 6 9 3 + -11 * / * 17 + 5 +",
"expectedOutput": "22",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "1\n18",
"expectedOutput": "18",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "3\n3 -4 -",
"expectedOutput": "7",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "7\n4 2 + 3 5 1 - * +",
"expectedOutput": "18",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "3\n5 2 /",
"expectedOutput": "2",
"isHidden": true,
"timeoutMs": 2000
}
]
},
{
"type": "CODING",
"order": 5,
"points": 15,
"prompt": "You are given an array of integers `temperatures` represents the daily temperatures, return an array `answer` such that `answer[i]` is the number of days you have to wait after the `i-th` day to get a warmer temperature. If there is no future day for which this is possible, keep `answer[i] == 0` instead.\n\n**Input Format:**\nThe first line contains an integer `n` representing the number of temperatures.\nThe second line contains `n` space-separated integers representing the sequence of temperatures.\n\n**Output Format:**\nPrint `n` space-separated integers denoting the number of days to wait for a warmer temperature for each day.\n\n**Constraints:**\n- `1 <= n <= 10^5`\n- `30 <= temperatures[i] <= 100`",
"starterCode": "// write your code here",
"testcases": [
{
"input": "8\n73 74 75 71 69 72 76 73",
"expectedOutput": "1 1 4 2 1 1 0 0",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "4\n30 40 50 60",
"expectedOutput": "1 1 1 0",
"isHidden": false,
"timeoutMs": 2000
},
{
"input": "4\n30 60 90 120",
"expectedOutput": "1 1 1 0",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "3\n30 30 30",
"expectedOutput": "0 0 0",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "5\n89 62 70 58 47",
"expectedOutput": "0 1 0 0 0",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "6\n50 50 49 48 47 51",
"expectedOutput": "5 4 3 2 1 0",
"isHidden": true,
"timeoutMs": 2000
},
{
"input": "4\n30 20 10 40",
"expectedOutput": "3 2 1 0",
"isHidden": true,
"timeoutMs": 2000
}
]
}
]
}