-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.json
More file actions
852 lines (852 loc) · 38.4 KB
/
db.json
File metadata and controls
852 lines (852 loc) · 38.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
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
{
"questions": [
{
"id": 1,
"title": "Evolutionary Anagram Solver",
"description": "Genetic algorithm approach for anagram generation",
"examples": [
{"id": 1, "input": {"source": "listen", "target": "silent"}, "output": 0},
{"id": 2, "input": {"source": "earth", "target": "heart"}, "output": 0}
],
"constraints": [
{"id": 1, "description": "Population size <= 1000"},
{"id": 2, "description": "Max generations 100"}
],
"test_cases": [
{"input": {"source": "test", "target": "sett"}, "exp_output": 0}
],
"difficulty_level": "Hard"
},
{
"id": 2,
"title": "Minimum Spanning Tree",
"description": "Find the MST using Kruskal's or Prim's algorithm",
"examples": [
{"id": 1, "input": {"graph": [[0,1,2], [1,2,3], [0,2,1]]}, "output": 3},
{"id": 2, "input": {"graph": [[0,1,4], [1,2,1], [2,0,3]]}, "output": 4}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 1000"}
],
"test_cases": [
{"input": {"graph": [[0,1,4], [1,2,1], [2,0,3]]}, "exp_output": 4}
],
"difficulty_level": "Medium"
},
{
"id": 3,
"title": "Knapsack Problem",
"description": "Solve 0/1 Knapsack using dynamic programming",
"examples": [
{"id": 1, "input": {"weights": [2,3,4], "values": [3,4,5], "capacity": 5}, "output": 7},
{"id": 2, "input": {"weights": [1,2,3], "values": [10,15,40], "capacity": 6}, "output": 55}
],
"constraints": [
{"id": 1, "description": "Number of items <= 1000"}
],
"test_cases": [
{"input": {"weights": [1,2,3], "values": [10,15,40], "capacity": 6}, "exp_output": 55}
],
"difficulty_level": "Hard"
},
{
"id": 4,
"title": "Traveling Salesman Problem",
"description": "Find the shortest tour that visits every city exactly once",
"examples": [
{"id": 1, "input": {"distances": [[0,10,15],[10,0,20],[15,20,0]]}, "output": 45},
{"id": 2, "input": {"distances": [[0,29,20],[29,0,15],[20,15,0]]}, "output": 50}
],
"constraints": [
{"id": 1, "description": "Number of cities <= 15"}
],
"test_cases": [
{"input": {"distances": [[0,29,20],[29,0,15],[20,15,0]]}, "exp_output": 50}
],
"difficulty_level": "Hard"
},
{
"id": 5,
"title": "Palindrome Partitioning",
"description": "Determine the minimum cuts needed to partition a string into palindromic substrings",
"examples": [
{"id": 1, "input": {"s": "aab"}, "output": 1},
{"id": 2, "input": {"s": "racecar"}, "output": 0}
],
"constraints": [
{"id": 1, "description": "String length <= 1000"}
],
"test_cases": [
{"input": {"s": "noonabbad"}, "exp_output": 2}
],
"difficulty_level": "Medium"
},
{
"id": 6,
"title": "Shortest Path in a Graph",
"description": "Find the shortest path between two nodes in a weighted graph",
"examples": [
{"id": 1, "input": {"graph": [[0,1,4],[1,2,6],[0,2,8]], "source": 0, "target": 2}, "output": 8},
{"id": 2, "input": {"graph": [[0,1,2],[1,2,3],[0,2,10]], "source": 0, "target": 2}, "output": 5}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 500"}
],
"test_cases": [
{"input": {"graph": [[0,1,2],[1,2,3],[0,2,10]], "source": 0, "target": 2}, "exp_output": 5}
],
"difficulty_level": "Medium"
},
{
"id": 7,
"title": "Sudoku Solver",
"description": "Fill in a partially completed sudoku board",
"examples": [
{
"id": 1,
"input": {
"board": [
[5,3,0,0,7,0,0,0,0],
[6,0,0,1,9,5,0,0,0],
[0,9,8,0,0,0,0,6,0],
[8,0,0,0,6,0,0,0,3],
[4,0,0,8,0,3,0,0,1],
[7,0,0,0,2,0,0,0,6],
[0,6,0,0,0,0,2,8,0],
[0,0,0,4,1,9,0,0,5],
[0,0,0,0,8,0,0,7,9]
]
},
"output": "solved board"
},
{
"id": 2,
"input": {
"board": [
[0,0,0,2,6,0,7,0,1],
[6,8,0,0,7,0,0,9,0],
[1,9,0,0,0,4,5,0,0],
[8,2,0,1,0,0,0,4,0],
[0,0,4,6,0,2,9,0,0],
[0,5,0,0,0,3,0,2,8],
[0,0,9,3,0,0,0,7,4],
[0,4,0,0,5,0,0,3,6],
[7,0,3,0,1,8,0,0,0]
]
},
"output": "solved board"
}
],
"constraints": [
{"id": 1, "description": "Board size is 9x9"}
],
"test_cases": [
{
"input": {
"board": [
[5,3,0,0,7,0,0,0,0],
[6,0,0,1,9,5,0,0,0],
[0,9,8,0,0,0,0,6,0],
[8,0,0,0,6,0,0,0,3],
[4,0,0,8,0,3,0,0,1],
[7,0,0,0,2,0,0,0,6],
[0,6,0,0,0,0,2,8,0],
[0,0,0,4,1,9,0,0,5],
[0,0,0,0,8,0,0,7,9]
]
},
"exp_output": "solved board"
}
],
"difficulty_level": "Hard"
},
{
"id": 8,
"title": "Longest Increasing Subsequence",
"description": "Find the length of the longest increasing subsequence in an array",
"examples": [
{"id": 1, "input": {"arr": [10,9,2,5,3,7,101,18]}, "output": 4},
{"id": 2, "input": {"arr": [0,1,0,3,2,3]}, "output": 4}
],
"constraints": [
{"id": 1, "description": "Array length <= 1000"}
],
"test_cases": [
{"input": {"arr": [10,9,2,5,3,7,101,18]}, "exp_output": 4}
],
"difficulty_level": "Medium"
},
{
"id": 9,
"title": "Max Flow in a Network",
"description": "Calculate the maximum flow in a network using the Ford-Fulkerson algorithm",
"examples": [
{"id": 1, "input": {"graph": [[0,16,13,0],[0,0,10,12],[0,4,0,14],[0,0,0,0]]}, "output": 23},
{"id": 2, "input": {"graph": [[0,10,10,0],[0,0,5,15],[0,0,0,10],[0,0,0,0]]}, "output": 20}
],
"constraints": [
{"id": 1, "description": "Graph size <= 1000 nodes"}
],
"test_cases": [
{"input": {"graph": [[0,16,13,0],[0,0,10,12],[0,4,0,14],[0,0,0,0]]}, "exp_output": 23}
],
"difficulty_level": "Hard"
},
{
"id": 10,
"title": "Word Ladder Transformation",
"description": "Transform one word to another by changing one letter at a time",
"examples": [
{"id": 1, "input": {"start": "hit", "end": "cog", "dict": ["hot","dot","dog","lot","log","cog"]}, "output": 5},
{"id": 2, "input": {"start": "game", "end": "thee", "dict": ["game","gave","tame","thee"]}, "output": 4}
],
"constraints": [
{"id": 1, "description": "Word length <= 10"}
],
"test_cases": [
{"input": {"start": "hit", "end": "cog", "dict": ["hot","dot","dog","lot","log","cog"]}, "exp_output": 5}
],
"difficulty_level": "Medium"
},
{
"id": 11,
"title": "Subset Sum Problem",
"description": "Determine if there exists a subset that sums to a given target",
"examples": [
{"id": 1, "input": {"arr": [3,34,4,12,5,2], "target": 9}, "output": true},
{"id": 2, "input": {"arr": [1,2,3], "target": 5}, "output": false}
],
"constraints": [
{"id": 1, "description": "Array length <= 100"}
],
"test_cases": [
{"input": {"arr": [3,34,4,12,5,2], "target": 9}, "exp_output": true}
],
"difficulty_level": "Medium"
},
{
"id": 12,
"title": "Merge Intervals",
"description": "Merge overlapping intervals",
"examples": [
{"id": 1, "input": {"intervals": [[1,3],[2,6],[8,10],[15,18]]}, "output": [[1,6],[8,10],[15,18]]},
{"id": 2, "input": {"intervals": [[1,4],[4,5]]}, "output": [[1,5]]}
],
"constraints": [
{"id": 1, "description": "Number of intervals <= 1000"}
],
"test_cases": [
{"input": {"intervals": [[1,3],[2,6],[8,10],[15,18]]}, "exp_output": [[1,6],[8,10],[15,18]]}
],
"difficulty_level": "Medium"
},
{
"id": 13,
"title": "Convex Hull Computation",
"description": "Compute the convex hull for a set of points",
"examples": [
{"id": 1, "input": {"points": [[0,3],[2,2],[1,1],[2,1],[3,0],[0,0],[3,3]]}, "output": [[0,0],[3,0],[3,3],[0,3]]},
{"id": 2, "input": {"points": [[1,1],[2,2],[3,3],[0,0]]}, "output": [[0,0],[3,3]]}
],
"constraints": [
{"id": 1, "description": "Number of points <= 1000"}
],
"test_cases": [
{"input": {"points": [[0,3],[2,2],[1,1],[2,1],[3,0],[0,0],[3,3]]}, "exp_output": [[0,0],[3,0],[3,3],[0,3]]}
],
"difficulty_level": "Medium"
},
{
"id": 14,
"title": "Finding Bridges in a Graph",
"description": "Identify all bridges in an undirected graph",
"examples": [
{"id": 1, "input": {"graph": {"0": [1], "1": [0,2], "2": [1,3], "3": [2]}}, "output": [[1,2]]},
{"id": 2, "input": {"graph": {"0": [1,2], "1": [0], "2": [0]}}, "output": []}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 1000"}
],
"test_cases": [
{"input": {"graph": {"0": [1], "1": [0,2], "2": [1,3], "3": [2]}}, "exp_output": [[1,2]]}
],
"difficulty_level": "Hard"
},
{
"id": 15,
"title": "Matrix Chain Multiplication",
"description": "Determine the most efficient way to multiply a chain of matrices",
"examples": [
{"id": 1, "input": {"dims": [10,30,5,60]}, "output": 4500},
{"id": 2, "input": {"dims": [40,20,30,10,30]}, "output": 26000}
],
"constraints": [
{"id": 1, "description": "Length of dims array <= 100"}
],
"test_cases": [
{"input": {"dims": [10,30,5,60]}, "exp_output": 4500}
],
"difficulty_level": "Medium"
},
{
"id": 16,
"title": "All-Pairs Shortest Path",
"description": "Compute shortest paths between every pair of vertices",
"examples": [
{"id": 1, "input": {"graph": [[0,3,1000000000],[3,0,1],[1000000000,1,0]]}, "output": [[0,3,4],[3,0,1],[4,1,0]]},
{"id": 2, "input": {"graph": [[0,5,1000000000],[5,0,2],[1000000000,2,0]]}, "output": [[0,5,7],[5,0,2],[7,2,0]]}
],
"constraints": [
{"id": 1, "description": "Graph size <= 500"}
],
"test_cases": [
{"input": {"graph": [[0,3,1000000000],[3,0,1],[1000000000,1,0]]}, "exp_output": [[0,3,1000000000],[3,0,1],[1000000000,1,0]]}
],
"difficulty_level": "Hard"
},
{
"id": 17,
"title": "Largest Rectangle in Histogram",
"description": "Find the largest rectangular area in a histogram",
"examples": [
{"id": 1, "input": {"heights": [2,1,5,6,2,3]}, "output": 10},
{"id": 2, "input": {"heights": [2,4]}, "output": 4}
],
"constraints": [
{"id": 1, "description": "Number of bars <= 1000"}
],
"test_cases": [
{"input": {"heights": [2,1,5,6,2,3]}, "exp_output": 10}
],
"difficulty_level": "Medium"
},
{
"id": 18,
"title": "Maximum Subarray Sum",
"description": "Find the contiguous subarray with the largest sum",
"examples": [
{"id": 1, "input": {"arr": [-2,1,-3,4,-1,2,1,-5,4]}, "output": 6},
{"id": 2, "input": {"arr": [1,2,3,4]}, "output": 10}
],
"constraints": [
{"id": 1, "description": "Array length <= 1000"}
],
"test_cases": [
{"input": {"arr": [-2,1,-3,4,-1,2,1,-5,4]}, "exp_output": 6}
],
"difficulty_level": "Medium"
},
{
"id": 19,
"title": "Word Break Problem",
"description": "Determine if a string can be segmented into a sequence of dictionary words",
"examples": [
{"id": 1, "input": {"s": "leetcode", "dict": ["leet","code"]}, "output": true},
{"id": 2, "input": {"s": "applepenapple", "dict": ["apple","pen"]}, "output": true}
],
"constraints": [
{"id": 1, "description": "String length <= 1000"}
],
"test_cases": [
{"input": {"s": "leetcode", "dict": ["leet","code"]}, "exp_output": true}
],
"difficulty_level": "Medium"
},
{
"id": 20,
"title": "Coin Change Problem",
"description": "Find the fewest coins needed to make a given amount",
"examples": [
{"id": 1, "input": {"coins": [1,2,5], "amount": 11}, "output": 3},
{"id": 2, "input": {"coins": [2], "amount": 3}, "output": -1}
],
"constraints": [
{"id": 1, "description": "Number of coins <= 100"}
],
"test_cases": [
{"input": {"coins": [1,2,5], "amount": 11}, "exp_output": 3}
],
"difficulty_level": "Medium"
},
{
"id": 21,
"title": "K-th Largest Element",
"description": "Find the kth largest element in an unsorted array",
"examples": [
{"id": 1, "input": {"arr": [3,2,1,5,6,4], "k": 2}, "output": 5},
{"id": 2, "input": {"arr": [3,2,3,1,2,4,5,5,6], "k": 4}, "output": 4}
],
"constraints": [
{"id": 1, "description": "Array length <= 1000"}
],
"test_cases": [
{"input": {"arr": [3,2,1,5,6,4], "k": 2}, "exp_output": 5}
],
"difficulty_level": "Medium"
},
{
"id": 22,
"title": "LRU Cache Implementation",
"description": "Implement an LRU cache with get and put methods",
"examples": [
{"id": 1, "input": {"operations": ["put 1,1", "put 2,2", "get 1", "put 3,3", "get 2"]}, "output": [1,-1]},
{"id": 2, "input": {"operations": ["put 1,10", "get 1"]}, "output": [10]}
],
"constraints": [
{"id": 1, "description": "Cache size <= 1000"}
],
"test_cases": [
{"input": {"operations": ["put 1,10", "get 1"]}, "exp_output": [10]}
],
"difficulty_level": "Medium"
},
{
"id": 23,
"title": "Regular Expression Matching",
"description": "Implement regular expression matching with support for '.' and '*'",
"examples": [
{"id": 1, "input": {"s": "aa", "p": "a*"}, "output": true},
{"id": 2, "input": {"s": "ab", "p": ".*"}, "output": true}
],
"constraints": [
{"id": 1, "description": "String length <= 1000"}
],
"test_cases": [
{"input": {"s": "aa", "p": "a*"}, "exp_output": true}
],
"difficulty_level": "Hard"
},
{
"id": 24,
"title": "Balanced Parentheses",
"description": "Check if the input string of parentheses is balanced",
"examples": [
{"id": 1, "input": {"s": "(())"}, "output": true},
{"id": 2, "input": {"s": "(()"}, "output": false}
],
"constraints": [
{"id": 1, "description": "String length <= 1000"}
],
"test_cases": [
{"input": {"s": "(())"}, "exp_output": true}
],
"difficulty_level": "Easy"
},
{
"id": 25,
"title": "Edit Distance Calculation",
"description": "Calculate the minimum edit distance between two strings",
"examples": [
{"id": 1, "input": {"s1": "horse", "s2": "ros"}, "output": 3},
{"id": 2, "input": {"s1": "intention", "s2": "execution"}, "output": 5}
],
"constraints": [
{"id": 1, "description": "String length <= 1000"}
],
"test_cases": [
{"input": {"s1": "horse", "s2": "ros"}, "exp_output": 3}
],
"difficulty_level": "Hard"
},
{
"id": 26,
"title": "N-Queens Problem",
"description": "Place N queens on an N×N chessboard such that no two queens threaten each other",
"examples": [
{"id": 1, "input": {"n": 4}, "output": "solution exists"},
{"id": 2, "input": {"n": 8}, "output": "solution exists"}
],
"constraints": [
{"id": 1, "description": "N <= 20"}
],
"test_cases": [
{"input": {"n": 4}, "exp_output": "solution exists"}
],
"difficulty_level": "Hard"
},
{
"id": 27,
"title": "Strongly Connected Components",
"description": "Find all strongly connected components in a directed graph",
"examples": [
{"id": 1, "input": {"graph": {"0": [1], "1": [2], "2": [0]}}, "output": [[0,1,2]]},
{"id": 2, "input": {"graph": {"0": [1], "1": [0,2], "2": [1]}}, "output": [[0,1],[1,2]]}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 1000"}
],
"test_cases": [
{"input": {"graph": {"0": [1], "1": [2], "2": [0]}}, "exp_output": [[0,1,2]]}
],
"difficulty_level": "Hard"
},
{
"id": 28,
"title": "Sliding Window Maximum",
"description": "Find the maximum value in each sliding window of size k in an array",
"examples": [
{"id": 1, "input": {"arr": [1,3,-1,-3,5,3,6,7], "k": 3}, "output": [3,3,5,7]},
{"id": 2, "input": {"arr": [9,11], "k": 2}, "output": [11]}
],
"constraints": [
{"id": 1, "description": "Array length <= 1000"}
],
"test_cases": [
{"input": {"arr": [1,3,-1,-3,5,3,6,7], "k": 3}, "exp_output": [3,3,5,7]}
],
"difficulty_level": "Medium"
},
{
"id": 29,
"title": "Median of Two Sorted Arrays",
"description": "Find the median of two sorted arrays",
"examples": [
{"id": 1, "input": {"arr1": [1,3], "arr2": [2]}, "output": 2},
{"id": 2, "input": {"arr1": [1,2], "arr2": [3,4]}, "output": 2.5}
],
"constraints": [
{"id": 1, "description": "Arrays size <= 1000"}
],
"test_cases": [
{"input": {"arr1": [1,3], "arr2": [2]}, "exp_output": 2}
],
"difficulty_level": "Hard"
},
{
"id": 30,
"title": "Binary Search Tree Validation",
"description": "Determine if a given binary tree is a valid binary search tree",
"examples": [
{"id": 1, "input": {"tree": {"val": 2, "left": {"val": 1}, "right": {"val": 3}}}, "output": true},
{"id": 2, "input": {"tree": {"val": 5, "left": {"val": 1}, "right": {"val": 4}}}, "output": false}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 1000"}
],
"test_cases": [
{"input": {"tree": {"val": 2, "left": {"val": 1}, "right": {"val": 3}}}, "exp_output": true}
],
"difficulty_level": "Medium"
},
{
"id": 31,
"title": "Topological Sorting",
"description": "Return one possible topological ordering of a directed acyclic graph",
"examples": [
{"id": 1, "input": {"graph": {"0": [1,2], "1": [3], "2": [3], "3": []}}, "output": [0,1,2,3]},
{"id": 2, "input": {"graph": {"0": [1], "1": [2], "2": []}}, "output": [0,1,2]}
],
"constraints": [
{"id": 1, "description": "Graph must be a DAG"}
],
"test_cases": [
{"input": {"graph": {"0": [1,2], "1": [3], "2": [3], "3": []}}, "exp_output": [0,1,2,3]}
],
"difficulty_level": "Medium"
},
{
"id": 32,
"title": "Maximum Bipartite Matching",
"description": "Find the maximum matching in a bipartite graph",
"examples": [
{"id": 1, "input": {"graph": [[1,3],[0,2],[1,3],[0,2]]}, "output": 2},
{"id": 2, "input": {"graph": [[0,2],[1,3]]}, "output": 2}
],
"constraints": [
{"id": 1, "description": "Graph size <= 1000 nodes"}
],
"test_cases": [
{"input": {"graph": [[1,3],[0,2],[1,3],[0,2]]}, "exp_output": 2}
],
"difficulty_level": "Hard"
},
{
"id": 33,
"title": "Two Sum Problem",
"description": "Find two numbers in an array that add up to a target sum",
"examples": [
{"id": 1, "input": {"arr": [2,7,11,15], "target": 9}, "output": [0,1]},
{"id": 2, "input": {"arr": [3,2,4], "target": 6}, "output": [1,2]}
],
"constraints": [
{"id": 1, "description": "Array length <= 1000"}
],
"test_cases": [
{"input": {"arr": [2,7,11,15], "target": 9}, "exp_output": [0,1]}
],
"difficulty_level": "Easy"
},
{
"id": 34,
"title": "Detect Cycle in Directed Graph",
"description": "Check if a directed graph contains a cycle",
"examples": [
{"id": 1, "input": {"graph": {"0": [1], "1": [2], "2": [0]}}, "output": true},
{"id": 2, "input": {"graph": {"0": [1], "1": [2], "2": []}}, "output": false}
],
"constraints": [
{"id": 1, "description": "Graph size <= 1000 nodes"}
],
"test_cases": [
{"input": {"graph": {"0": [1], "1": [2], "2": [0]}}, "exp_output": true}
],
"difficulty_level": "Medium"
},
{
"id": 35,
"title": "Maximum Profit in Stock Trading",
"description": "Calculate the maximum profit from stock trading with at most one transaction",
"examples": [
{"id": 1, "input": {"prices": [7,1,5,3,6,4]}, "output": 5},
{"id": 2, "input": {"prices": [7,6,4,3,1]}, "output": 0}
],
"constraints": [
{"id": 1, "description": "Number of prices <= 1000"}
],
"test_cases": [
{"input": {"prices": [7,1,5,3,6,4]}, "exp_output": 5}
],
"difficulty_level": "Easy"
},
{
"id": 36,
"title": "Online Stock Span Problem",
"description": "Calculate the stock span for each day given a list of daily prices",
"examples": [
{"id": 1, "input": {"prices": [100,80,60,70,60,75,85]}, "output": [1,1,1,2,1,4,6]},
{"id": 2, "input": {"prices": [30,40,50,60]}, "output": [1,2,3,4]}
],
"constraints": [
{"id": 1, "description": "Number of days <= 1000"}
],
"test_cases": [
{"input": {"prices": [100,80,60,70,60,75,85]}, "exp_output": [1,1,1,2,1,4,6]}
],
"difficulty_level": "Medium"
},
{
"id": 37,
"title": "Shortest Common Supersequence",
"description": "Find the shortest common supersequence of two strings",
"examples": [
{"id": 1, "input": {"s1": "abac", "s2": "cab"}, "output": "cabac"},
{"id": 2, "input": {"s1": "geek", "s2": "eke"}, "output": "geeke"}
],
"constraints": [
{"id": 1, "description": "String length <= 1000"}
],
"test_cases": [
{"input": {"s1": "abac", "s2": "cab"}, "exp_output": "cabac"}
],
"difficulty_level": "Hard"
},
{
"id": 38,
"title": "Graph Coloring Problem",
"description": "Determine if a graph can be colored using at most M colors",
"examples": [
{"id": 1, "input": {"graph": {"0": [1,2], "1": [0,2], "2": [0,1]}, "M": 3}, "output": true},
{"id": 2, "input": {"graph": {"0": [1,2], "1": [0,2], "2": [0,1]}, "M": 2}, "output": false}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 100"}
],
"test_cases": [
{"input": {"graph": {"0": [1,2], "1": [0,2], "2": [0,1]}, "M": 3}, "exp_output": true}
],
"difficulty_level": "Hard"
},
{
"id": 39,
"title": "Celebrity Identification Problem",
"description": "Identify the celebrity in a group of people, if one exists",
"examples": [
{"id": 1, "input": {"matrix": [[0,1,0],[0,0,0],[0,1,0]]}, "output": 1},
{"id": 2, "input": {"matrix": [[0,1,0],[1,0,0],[0,0,0]]}, "output": -1}
],
"constraints": [
{"id": 1, "description": "Group size <= 100"}
],
"test_cases": [
{"input": {"matrix": [[0,1,0],[0,0,0],[0,1,0]]}, "exp_output": 1}
],
"difficulty_level": "Medium"
},
{
"id": 40,
"title": "Fibonacci Sequence Calculation",
"description": "Calculate the nth Fibonacci number",
"examples": [
{"id": 1, "input": {"n": 10}, "output": 55},
{"id": 2, "input": {"n": 5}, "output": 5}
],
"constraints": [
{"id": 1, "description": "n <= 50"}
],
"test_cases": [
{"input": {"n": 10}, "exp_output": 55}
],
"difficulty_level": "Easy"
},
{
"id": 41,
"title": "Find Duplicate in an Array",
"description": "Find any duplicate number in an array",
"examples": [
{"id": 1, "input": {"arr": [1,3,4,2,2]}, "output": 2},
{"id": 2, "input": {"arr": [3,1,3,4,2]}, "output": 3}
],
"constraints": [
{"id": 1, "description": "Array length <= 1000"}
],
"test_cases": [
{"input": {"arr": [1,3,4,2,2]}, "exp_output": 2}
],
"difficulty_level": "Easy"
},
{
"id": 42,
"title": "Search in Rotated Sorted Array",
"description": "Search for a target value in a rotated sorted array",
"examples": [
{"id": 1, "input": {"arr": [4,5,6,7,0,1,2], "target": 0}, "output": 4},
{"id": 2, "input": {"arr": [4,5,6,7,0,1,2], "target": 3}, "output": -1}
],
"constraints": [
{"id": 1, "description": "Array length <= 1000"}
],
"test_cases": [
{"input": {"arr": [4,5,6,7,0,1,2], "target": 0}, "exp_output": 4}
],
"difficulty_level": "Medium"
},
{
"id": 43,
"title": "Largest Connected Component",
"description": "Find the largest connected component in an undirected graph",
"examples": [
{"id": 1, "input": {"graph": {"0": [1], "1": [0,2], "2": [1]}}, "output": 3},
{"id": 2, "input": {"graph": {"0": [1], "1": [0]}}, "output": 2}
],
"constraints": [
{"id": 1, "description": "Graph size <= 1000 nodes"}
],
"test_cases": [
{"input": {"graph": {"0": [1], "1": [0,2], "2": [1]}}, "exp_output": 3}
],
"difficulty_level": "Medium"
},
{
"id": 44,
"title": "Implementing Dijkstra’s Algorithm",
"description": "Find the shortest paths from a source to all vertices in a weighted graph",
"examples": [
{"id": 1, "input": {"graph": [[0,10,3],[1000000000,0,1],[1000000000,1000000000,0]]}, "output": [0,4,3]},
{"id": 2, "input": {"graph": [[0,5,1000000000],[1000000000,0,2],[1000000000,1000000000,0]]}, "output": [0,5,7]}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 1000"}
],
"test_cases": [
{"input": {"graph": [[0,10,3],[1000000000,0,1],[1000000000,1000000000,0]]}, "exp_output": [0,4,3]}
],
"difficulty_level": "Medium"
},
{
"id": 45,
"title": "Construct Binary Tree from Traversals",
"description": "Construct a binary tree given its preorder and inorder traversals",
"examples": [
{"id": 1, "input": {"preorder": [3,9,20,15,7], "inorder": [9,3,15,20,7]}, "output": "binary tree"},
{"id": 2, "input": {"preorder": [1,2,3], "inorder": [2,1,3]}, "output": "binary tree"}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 1000"}
],
"test_cases": [
{"input": {"preorder": [3,9,20,15,7], "inorder": [9,3,15,20,7]}, "exp_output": "binary tree"}
],
"difficulty_level": "Medium"
},
{
"id": 46,
"title": "Implementing Trie Data Structure",
"description": "Implement a trie with insert, search, and startsWith methods",
"examples": [
{"id": 1, "input": {"words": ["apple","app"]}, "output": true},
{"id": 2, "input": {"words": ["banana","band"]}, "output": true}
],
"constraints": [
{"id": 1, "description": "Number of words <= 1000"}
],
"test_cases": [
{"input": {"words": ["apple","app"]}, "exp_output": true}
],
"difficulty_level": "Medium"
},
{
"id": 47,
"title": "3-Sum Closest Problem",
"description": "Find three integers in an array such that the sum is closest to a given target",
"examples": [
{"id": 1, "input": {"arr": [-1,2,1,-4], "target": 1}, "output": 2},
{"id": 2, "input": {"arr": [0,0,0], "target": 1}, "output": 0}
],
"constraints": [
{"id": 1, "description": "Array length <= 1000"}
],
"test_cases": [
{"input": {"arr": [-1,2,1,-4], "target": 1}, "exp_output": 2}
],
"difficulty_level": "Medium"
},
{
"id": 48,
"title": "Reverse Nodes in K-Group",
"description": "Reverse nodes of a linked list in groups of k",
"examples": [
{"id": 1, "input": {"list": [1,2,3,4,5], "k": 2}, "output": [2,1,4,3,5]},
{"id": 2, "input": {"list": [1,2,3,4,5], "k": 3}, "output": [3,2,1,4,5]}
],
"constraints": [
{"id": 1, "description": "Length of list <= 1000"}
],
"test_cases": [
{"input": {"list": [1,2,3,4,5], "k": 2}, "exp_output": [2,1,4,3,5]}
],
"difficulty_level": "Hard"
},
{
"id": 49,
"title": "Design Snake and Ladder Game",
"description": "Implement the logic for a snake and ladder game",
"examples": [
{"id": 1, "input": {"moves": [1,2,3]}, "output": "game state"},
{"id": 2, "input": {"moves": [4,5,6]}, "output": "game state"}
],
"constraints": [
{"id": 1, "description": "Board size is fixed at 100"}
],
"test_cases": [
{"input": {"moves": [1,2,3]}, "exp_output": "game state"}
],
"difficulty_level": "Medium"
},
{
"id": 50,
"title": "Graph Bipartiteness Checker",
"description": "Determine whether a given graph is bipartite",
"examples": [
{"id": 1, "input": {"graph": [[1,3],[0,2],[1,3],[0,2]]}, "output": true},
{"id": 2, "input": {"graph": [[0,1],[1,2],[2,0]]}, "output": false}
],
"constraints": [
{"id": 1, "description": "Number of nodes <= 1000"}
],
"test_cases": [
{"input": {"graph": [[0,1],[1,2],[2,0]]}, "exp_output": false}
],
"difficulty_level": "Medium"
}
]
}