-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathques.json
More file actions
454 lines (454 loc) · 23 KB
/
Copy pathques.json
File metadata and controls
454 lines (454 loc) · 23 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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
{
"users": [
{
"id": 1,
"username": "student",
"passwordHash": "student123",
"email": "anaya.sharma@sharda.edu",
"fullName": "Anaya Sharma",
"studentId": "SEB-2026-001",
"role": "student",
"department": "Computer Science",
"course": "B.Tech",
"branch": "Computer Science & Engineering",
"university": "Sharda University",
"location": "Greater Noida, Uttar Pradesh"
},
{
"id": 2,
"username": "student_002",
"passwordHash": "code2026",
"email": "rishi.verma@sharda.edu",
"fullName": "Rishi Verma",
"studentId": "SEB-2026-002",
"role": "student",
"department": "Computer Science",
"course": "B.Tech",
"branch": "Computer Science & Engineering",
"university": "Sharda University",
"location": "Greater Noida, Uttar Pradesh"
},
{
"id": 101,
"username": "admin",
"passwordHash": "admin123",
"email": "invigilator@sharda.edu",
"fullName": "Dr. Nidhi Kapoor",
"studentId": "INV-2026-001",
"role": "admin",
"department": "Examination Cell",
"course": "Faculty",
"branch": "Assessment Operations",
"university": "Sharda University",
"location": "Greater Noida, Uttar Pradesh"
}
],
"exams": [
{
"id": 501,
"code": "SEB-DSA-APR-2026",
"name": "Secure Coding Assessment - April 2026",
"description": "Interview-style data structures and algorithms round with mixed MCQ and coding tasks.",
"durationMinutes": 120,
"startTime": "2026-04-01T08:00:00Z",
"endTime": "2026-04-01T12:00:00Z",
"passingScore": 60,
"status": "active"
}
],
"questions": [
{
"id": 1001,
"examId": 501,
"orderIndex": 1,
"section": "Coding Challenge",
"type": "coding",
"title": "Two Sum",
"prompt": "Given an array of integers nums and an integer target, return the indices of the two numbers such that they add up to target. Each input has exactly one valid answer, and you may not use the same element twice.",
"difficulty": "easy",
"points": 15,
"functionName": "twoSum",
"languages": ["javascript", "python", "cpp"],
"constraints": [
"2 <= nums.length <= 10^4",
"-10^9 <= nums[i], target <= 10^9",
"Exactly one valid pair exists"
],
"examples": [
{
"input": "nums = [2,7,11,15], target = 9",
"output": "[0,1]",
"explanation": "nums[0] + nums[1] == 9"
},
{
"input": "nums = [3,2,4], target = 6",
"output": "[1,2]"
}
],
"starterCode": {
"javascript": "function twoSum(nums, target) {\n const seen = new Map();\n for (let i = 0; i < nums.length; i += 1) {\n const complement = target - nums[i];\n if (seen.has(complement)) {\n return [seen.get(complement), i];\n }\n seen.set(nums[i], i);\n }\n return [];\n}\n",
"python": "def twoSum(nums, target):\n seen = {}\n for i, value in enumerate(nums):\n complement = target - value\n if complement in seen:\n return [seen[complement], i]\n seen[value] = i\n return []\n",
"cpp": "#include <vector>\n#include <unordered_map>\nusing namespace std;\n\nvector<int> twoSum(vector<int> nums, int target) {\n unordered_map<int, int> seen;\n for (int i = 0; i < static_cast<int>(nums.size()); ++i) {\n int complement = target - nums[i];\n if (seen.count(complement)) {\n return {seen[complement], i};\n }\n seen[nums[i]] = i;\n }\n return {};\n}\n"
},
"testCases": [
{
"input": { "nums": [2, 7, 11, 15], "target": 9 },
"output": [0, 1],
"hidden": false,
"description": "Basic pair"
},
{
"input": { "nums": [3, 2, 4], "target": 6 },
"output": [1, 2],
"hidden": false,
"description": "Out-of-order pair"
},
{
"input": { "nums": [3, 3], "target": 6 },
"output": [0, 1],
"hidden": true,
"description": "Duplicate values"
},
{
"input": { "nums": [-1, -2, -3, 5, 10], "target": 8 },
"output": [2, 4],
"hidden": true,
"description": "Negative values"
}
]
},
{
"id": 1002,
"examId": 501,
"orderIndex": 2,
"section": "Coding Challenge",
"type": "coding",
"title": "Search in Rotated Sorted Array",
"prompt": "You are given an array sorted in ascending order and rotated at an unknown pivot. Return the index of target if it exists, otherwise return -1. Assume all values are distinct.",
"difficulty": "medium",
"points": 18,
"functionName": "search",
"languages": ["javascript", "python", "cpp"],
"constraints": [
"1 <= nums.length <= 5000",
"All nums values are distinct",
"Expected time complexity is O(log n)"
],
"examples": [
{
"input": "nums = [4,5,6,7,0,1,2], target = 0",
"output": "4"
},
{
"input": "nums = [4,5,6,7,0,1,2], target = 3",
"output": "-1"
}
],
"starterCode": {
"javascript": "function search(nums, target) {\n let left = 0;\n let right = nums.length - 1;\n\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n if (nums[mid] === target) {\n return mid;\n }\n\n if (nums[left] <= nums[mid]) {\n if (target >= nums[left] && target < nums[mid]) {\n right = mid - 1;\n } else {\n left = mid + 1;\n }\n } else {\n if (target > nums[mid] && target <= nums[right]) {\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n }\n\n return -1;\n}\n",
"python": "def search(nums, target):\n left, right = 0, len(nums) - 1\n while left <= right:\n mid = (left + right) // 2\n if nums[mid] == target:\n return mid\n if nums[left] <= nums[mid]:\n if nums[left] <= target < nums[mid]:\n right = mid - 1\n else:\n left = mid + 1\n else:\n if nums[mid] < target <= nums[right]:\n left = mid + 1\n else:\n right = mid - 1\n return -1\n",
"cpp": "#include <vector>\nusing namespace std;\n\nint search(vector<int> nums, int target) {\n int left = 0;\n int right = static_cast<int>(nums.size()) - 1;\n while (left <= right) {\n int mid = left + (right - left) / 2;\n if (nums[mid] == target) {\n return mid;\n }\n if (nums[left] <= nums[mid]) {\n if (target >= nums[left] && target < nums[mid]) {\n right = mid - 1;\n } else {\n left = mid + 1;\n }\n } else {\n if (target > nums[mid] && target <= nums[right]) {\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n }\n return -1;\n}\n"
},
"testCases": [
{
"input": { "nums": [4, 5, 6, 7, 0, 1, 2], "target": 0 },
"output": 4,
"hidden": false,
"description": "Target in rotated half"
},
{
"input": { "nums": [4, 5, 6, 7, 0, 1, 2], "target": 3 },
"output": -1,
"hidden": false,
"description": "Missing target"
},
{
"input": { "nums": [5, 1, 3], "target": 3 },
"output": 2,
"hidden": true,
"description": "Small rotated input"
},
{
"input": { "nums": [7, 8, 1, 2, 3, 4, 5, 6], "target": 1 },
"output": 2,
"hidden": true,
"description": "Pivot near middle"
}
]
},
{
"id": 1003,
"examId": 501,
"orderIndex": 3,
"section": "Coding Challenge",
"type": "coding",
"title": "Longest Valid Parentheses",
"prompt": "Given a string containing only '(' and ')', return the length of the longest valid parentheses substring.",
"difficulty": "hard",
"points": 22,
"functionName": "longestValidParentheses",
"languages": ["javascript", "python", "cpp"],
"constraints": ["0 <= s.length <= 3 * 10^4"],
"examples": [
{
"input": "s = \"(()\"",
"output": "2"
},
{
"input": "s = \")()())\"",
"output": "4"
}
],
"starterCode": {
"javascript": "function longestValidParentheses(s) {\n const dp = new Array(s.length).fill(0);\n let best = 0;\n\n for (let i = 1; i < s.length; i += 1) {\n if (s[i] === ')') {\n if (s[i - 1] === '(') {\n dp[i] = (i >= 2 ? dp[i - 2] : 0) + 2;\n } else {\n const openIndex = i - dp[i - 1] - 1;\n if (openIndex >= 0 && s[openIndex] === '(') {\n dp[i] = dp[i - 1] + 2 + (openIndex >= 1 ? dp[openIndex - 1] : 0);\n }\n }\n best = Math.max(best, dp[i]);\n }\n }\n\n return best;\n}\n",
"python": "def longestValidParentheses(s):\n dp = [0] * len(s)\n best = 0\n for i in range(1, len(s)):\n if s[i] == ')':\n if s[i - 1] == '(':\n dp[i] = (dp[i - 2] if i >= 2 else 0) + 2\n else:\n open_index = i - dp[i - 1] - 1\n if open_index >= 0 and s[open_index] == '(':\n dp[i] = dp[i - 1] + 2 + (dp[open_index - 1] if open_index >= 1 else 0)\n best = max(best, dp[i])\n return best\n",
"cpp": "#include <string>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\nint longestValidParentheses(string s) {\n vector<int> dp(s.size(), 0);\n int best = 0;\n for (int i = 1; i < static_cast<int>(s.size()); ++i) {\n if (s[i] == ')') {\n if (s[i - 1] == '(') {\n dp[i] = (i >= 2 ? dp[i - 2] : 0) + 2;\n } else {\n int openIndex = i - dp[i - 1] - 1;\n if (openIndex >= 0 && s[openIndex] == '(') {\n dp[i] = dp[i - 1] + 2 + (openIndex >= 1 ? dp[openIndex - 1] : 0);\n }\n }\n best = max(best, dp[i]);\n }\n }\n return best;\n}\n"
},
"testCases": [
{
"input": { "s": "(()" },
"output": 2,
"hidden": false,
"description": "Single partial match"
},
{
"input": { "s": ")()())" },
"output": 4,
"hidden": false,
"description": "Mixed invalid and valid"
},
{
"input": { "s": "" },
"output": 0,
"hidden": true,
"description": "Empty string"
},
{
"input": { "s": "()(())" },
"output": 6,
"hidden": true,
"description": "Nested valid block"
}
]
},
{
"id": 1004,
"examId": 501,
"orderIndex": 4,
"section": "Coding Challenge",
"type": "coding",
"title": "Longest Substring Without Repeating Characters",
"prompt": "Given a string s, return the length of the longest substring without repeating characters. Aim for an O(n) solution using a sliding window.",
"difficulty": "medium",
"points": 18,
"functionName": "lengthOfLongestSubstring",
"languages": ["javascript", "python", "cpp"],
"constraints": [
"0 <= s.length <= 5 * 10^4",
"s can contain letters, digits, spaces, and symbols"
],
"examples": [
{
"input": "s = \"abcabcbb\"",
"output": "3",
"explanation": "\"abc\" is the longest substring without duplicates."
},
{
"input": "s = \"pwwkew\"",
"output": "3"
}
],
"starterCode": {
"javascript": "function lengthOfLongestSubstring(s) {\n const lastSeen = new Map();\n let left = 0;\n let best = 0;\n\n for (let right = 0; right < s.length; right += 1) {\n if (lastSeen.has(s[right]) && lastSeen.get(s[right]) >= left) {\n left = lastSeen.get(s[right]) + 1;\n }\n lastSeen.set(s[right], right);\n best = Math.max(best, right - left + 1);\n }\n\n return best;\n}\n",
"python": "def lengthOfLongestSubstring(s):\n last_seen = {}\n left = 0\n best = 0\n for right, ch in enumerate(s):\n if ch in last_seen and last_seen[ch] >= left:\n left = last_seen[ch] + 1\n last_seen[ch] = right\n best = max(best, right - left + 1)\n return best\n",
"cpp": "#include <string>\n#include <unordered_map>\n#include <algorithm>\nusing namespace std;\n\nint lengthOfLongestSubstring(string s) {\n unordered_map<char, int> lastSeen;\n int left = 0;\n int best = 0;\n for (int right = 0; right < static_cast<int>(s.size()); ++right) {\n if (lastSeen.count(s[right]) && lastSeen[s[right]] >= left) {\n left = lastSeen[s[right]] + 1;\n }\n lastSeen[s[right]] = right;\n best = max(best, right - left + 1);\n }\n return best;\n}\n"
},
"testCases": [
{
"input": { "s": "abcabcbb" },
"output": 3,
"hidden": false,
"description": "Repeat after prefix"
},
{
"input": { "s": "bbbbb" },
"output": 1,
"hidden": false,
"description": "All same character"
},
{
"input": { "s": "pwwkew" },
"output": 3,
"hidden": true,
"description": "Window reset"
},
{
"input": { "s": "dvdf" },
"output": 3,
"hidden": true,
"description": "Non-adjacent repeat"
}
]
},
{
"id": 1005,
"examId": 501,
"orderIndex": 5,
"section": "Coding Challenge",
"type": "coding",
"title": "Merge Intervals",
"prompt": "You are given an array of intervals where intervals[i] = [start, end]. Merge all overlapping intervals and return an array of the non-overlapping intervals covering the same ranges.",
"difficulty": "medium",
"points": 20,
"functionName": "mergeIntervals",
"languages": ["javascript", "python", "cpp"],
"constraints": [
"1 <= intervals.length <= 10^4",
"0 <= start <= end <= 10^4"
],
"examples": [
{
"input": "intervals = [[1,3],[2,6],[8,10],[15,18]]",
"output": "[[1,6],[8,10],[15,18]]"
},
{
"input": "intervals = [[1,4],[4,5]]",
"output": "[[1,5]]"
}
],
"starterCode": {
"javascript": "function mergeIntervals(intervals) {\n if (intervals.length <= 1) {\n return intervals;\n }\n\n const sorted = intervals.slice().sort((a, b) => a[0] - b[0]);\n const merged = [sorted[0].slice()];\n\n for (let i = 1; i < sorted.length; i += 1) {\n const current = sorted[i];\n const last = merged[merged.length - 1];\n if (current[0] <= last[1]) {\n last[1] = Math.max(last[1], current[1]);\n } else {\n merged.push(current.slice());\n }\n }\n\n return merged;\n}\n",
"python": "def mergeIntervals(intervals):\n if len(intervals) <= 1:\n return intervals\n intervals = sorted(intervals)\n merged = [intervals[0][:]]\n for start, end in intervals[1:]:\n last = merged[-1]\n if start <= last[1]:\n last[1] = max(last[1], end)\n else:\n merged.append([start, end])\n return merged\n",
"cpp": "#include <vector>\n#include <algorithm>\nusing namespace std;\n\nvector<vector<int>> mergeIntervals(vector<vector<int>> intervals) {\n if (intervals.size() <= 1) {\n return intervals;\n }\n sort(intervals.begin(), intervals.end());\n vector<vector<int>> merged;\n merged.push_back(intervals[0]);\n for (size_t i = 1; i < intervals.size(); ++i) {\n if (intervals[i][0] <= merged.back()[1]) {\n merged.back()[1] = max(merged.back()[1], intervals[i][1]);\n } else {\n merged.push_back(intervals[i]);\n }\n }\n return merged;\n}\n"
},
"testCases": [
{
"input": { "intervals": [[1, 3], [2, 6], [8, 10], [15, 18]] },
"output": [[1, 6], [8, 10], [15, 18]],
"hidden": false,
"description": "Classic overlap"
},
{
"input": { "intervals": [[1, 4], [4, 5]] },
"output": [[1, 5]],
"hidden": false,
"description": "Touching endpoints"
},
{
"input": { "intervals": [[1, 4], [0, 2], [3, 5]] },
"output": [[0, 5]],
"hidden": true,
"description": "Cascade merge"
},
{
"input": { "intervals": [[6, 8], [1, 9], [2, 4], [4, 7]] },
"output": [[1, 9]],
"hidden": true,
"description": "Contained ranges"
}
]
},
{
"id": 1006,
"examId": 501,
"orderIndex": 6,
"section": "Coding Challenge",
"type": "coding",
"title": "Number of Islands",
"prompt": "Given an m x n grid of '1's and '0's, return the number of islands. An island is formed by horizontally or vertically adjacent lands, and the grid edges are surrounded by water.",
"difficulty": "medium",
"points": 22,
"functionName": "numIslands",
"languages": ["javascript", "python", "cpp"],
"constraints": ["1 <= m, n <= 300"],
"examples": [
{
"input": "grid = [[\"1\",\"1\",\"1\",\"1\",\"0\"],[\"1\",\"1\",\"0\",\"1\",\"0\"],[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\",\"0\"]]",
"output": "1"
},
{
"input": "grid = [[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"1\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"1\",\"1\"]]",
"output": "3"
}
],
"starterCode": {
"javascript": "function numIslands(grid) {\n const rows = grid.length;\n const cols = grid[0].length;\n let islands = 0;\n const seen = Array.from({ length: rows }, () => Array(cols).fill(false));\n\n function dfs(row, col) {\n if (row < 0 || col < 0 || row >= rows || col >= cols) {\n return;\n }\n if (seen[row][col] || grid[row][col] !== '1') {\n return;\n }\n seen[row][col] = true;\n dfs(row + 1, col);\n dfs(row - 1, col);\n dfs(row, col + 1);\n dfs(row, col - 1);\n }\n\n for (let row = 0; row < rows; row += 1) {\n for (let col = 0; col < cols; col += 1) {\n if (!seen[row][col] && grid[row][col] === '1') {\n islands += 1;\n dfs(row, col);\n }\n }\n }\n\n return islands;\n}\n",
"python": "def numIslands(grid):\n rows = len(grid)\n cols = len(grid[0])\n seen = [[False] * cols for _ in range(rows)]\n\n def dfs(r, c):\n if r < 0 or c < 0 or r >= rows or c >= cols:\n return\n if seen[r][c] or grid[r][c] != '1':\n return\n seen[r][c] = True\n dfs(r + 1, c)\n dfs(r - 1, c)\n dfs(r, c + 1)\n dfs(r, c - 1)\n\n islands = 0\n for r in range(rows):\n for c in range(cols):\n if not seen[r][c] and grid[r][c] == '1':\n islands += 1\n dfs(r, c)\n return islands\n",
"cpp": "#include <vector>\n#include <string>\nusing namespace std;\n\nint numIslands(vector<vector<string>> grid) {\n int rows = static_cast<int>(grid.size());\n int cols = static_cast<int>(grid[0].size());\n vector<vector<int>> seen(rows, vector<int>(cols, 0));\n\n auto dfs = [&](auto&& self, int r, int c) -> void {\n if (r < 0 || c < 0 || r >= rows || c >= cols) {\n return;\n }\n if (seen[r][c] || grid[r][c] != \"1\") {\n return;\n }\n seen[r][c] = 1;\n self(self, r + 1, c);\n self(self, r - 1, c);\n self(self, r, c + 1);\n self(self, r, c - 1);\n };\n\n int islands = 0;\n for (int r = 0; r < rows; ++r) {\n for (int c = 0; c < cols; ++c) {\n if (!seen[r][c] && grid[r][c] == \"1\") {\n ++islands;\n dfs(dfs, r, c);\n }\n }\n }\n return islands;\n}\n"
},
"testCases": [
{
"input": { "grid": [["1", "1", "1", "1", "0"], ["1", "1", "0", "1", "0"], ["1", "1", "0", "0", "0"], ["0", "0", "0", "0", "0"]] },
"output": 1,
"hidden": false,
"description": "Single island"
},
{
"input": { "grid": [["1", "1", "0", "0", "0"], ["1", "1", "0", "0", "0"], ["0", "0", "1", "0", "0"], ["0", "0", "0", "1", "1"]] },
"output": 3,
"hidden": false,
"description": "Separated components"
},
{
"input": { "grid": [["1", "0", "1", "0", "1"], ["0", "1", "0", "1", "0"], ["1", "0", "1", "0", "1"]] },
"output": 8,
"hidden": true,
"description": "Alternating islands"
},
{
"input": { "grid": [["1", "1", "1"], ["0", "1", "0"], ["1", "1", "1"]] },
"output": 1,
"hidden": true,
"description": "Cross-shaped land"
}
]
},
{
"id": 2001,
"examId": 501,
"orderIndex": 7,
"section": "Multiple Choice",
"type": "mcq",
"title": "Merge Sort Complexity",
"prompt": "What is the time complexity of merge sort in the best, average, and worst cases?",
"difficulty": "easy",
"points": 5,
"options": ["O(n)", "O(n log n)", "O(n^2)", "O(log n)"],
"correctOption": 1,
"explanation": "Merge sort always splits the array over log n levels and processes n elements per level."
},
{
"id": 2002,
"examId": 501,
"orderIndex": 8,
"section": "Multiple Choice",
"type": "mcq",
"title": "Binary Search Tree Property",
"prompt": "Which statement correctly describes a binary search tree?",
"difficulty": "easy",
"points": 5,
"options": [
"Every node has exactly two children.",
"Values in the left subtree are smaller and values in the right subtree are larger.",
"The tree is always perfectly balanced.",
"Nodes are stored in insertion order."
],
"correctOption": 1,
"explanation": "BST ordering is defined by left subtree values being smaller and right subtree values being larger than the node."
},
{
"id": 2003,
"examId": 501,
"orderIndex": 9,
"section": "Multiple Choice",
"type": "mcq",
"title": "Hash Map Collision Strategy",
"prompt": "Which technique resolves collisions by storing multiple entries in the same bucket and searching only within that bucket?",
"difficulty": "medium",
"points": 5,
"options": ["Open addressing with linear probing", "Separate chaining", "Double hashing", "Robin Hood hashing"],
"correctOption": 1,
"explanation": "Separate chaining stores colliding keys in a bucket-level collection such as a linked list or dynamic array."
}
]
}