-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverse.json
12513 lines (12512 loc) · 702 KB
/
reverse.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
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
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"Given two strings str1 and str2,\u00a0return the shortest string that has both str1\u00a0and str2\u00a0as subsequences.\u00a0\u00a0If multiple answers exist, you may return any of them.(A string S is a subsequence of string T if deleting some number of characters from T (possibly 0, and the characters are chosen anywhere from T) results in the string S.)\u00a0": [
"shortest-common-supersequence",
[
"longest-common-subsequence"
],
[
"Dynamic Programming"
]
],
"Given a file and assume that you can only read the file using a given method\u00a0read4, implement a method to read n characters.\u00a0Method read4: The API\u00a0read4 reads 4 consecutive characters from the file, then writes those characters into the buffer array buf.The return value is the number of actual characters read.": [
"read-n-characters-given-read4",
[
"read-n-characters-given-read4-ii-call-multiple-times"
],
[
"String"
]
],
"Design and implement a TwoSum class. It should support the following operations: add and find.add - Add the number to an internal data structure.find - Find if there exists any pair of numbers which sum is equal to the value.": [
"two-sum-iii-data-structure-design",
[
"two-sum-iv-input-is-a-bst",
"unique-word-abbreviation",
"two-sum"
],
[
"Hash Table",
"Design"
]
],
"Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.": [
"shortest-word-distance",
[
"shortest-word-distance-iii",
"shortest-word-distance-ii"
],
[
"Array"
]
],
"A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Write a function to determine if a number is strobogrammatic. The number is represented as a string.\u00a0": [
"strobogrammatic-number",
[
"confusing-number",
"strobogrammatic-number-iii",
"strobogrammatic-number-ii"
],
[
"Hash Table",
"Math"
]
],
"Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.": [
"meeting-rooms",
[
"meeting-rooms-ii",
"merge-intervals"
],
[
"Sort"
]
],
"There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.The cost of painting each house with a certain color is represented by a n x 3 cost matrix. ": [
"paint-house",
[
"paint-fence",
"paint-house-ii",
"house-robber-ii",
"house-robber"
],
[
"Dynamic Programming"
]
],
"Given a string, determine if a permutation of the string could form a palindrome.": [
"palindrome-permutation",
[
"longest-palindrome",
"palindrome-permutation-ii",
"valid-anagram",
"longest-palindromic-substring"
],
[
"Hash Table"
]
],
"Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.": [
"closest-binary-search-tree-value",
[
"search-in-a-binary-search-tree",
"closest-binary-search-tree-value-ii",
"count-complete-tree-nodes"
],
[
"Binary Search",
"Tree"
]
],
"There is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adjacent fence posts have the same color.Return the total number of ways you can paint the fence.": [
"paint-fence",
[
"paint-house-ii",
"paint-house",
"house-robber-ii",
"house-robber"
],
[
"Dynamic Programming"
]
],
"You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive \"++\" into \"--\". The game ends when a person can no longer make a move and therefore the other person will be the winner.Write a function to compute all possible states of the string after one valid move.": [
"flip-game",
[
"flip-game-ii"
],
[
"String"
]
],
"Given a nested list of integers, return the sum of all integers in the list weighted by their depth.Each element is either an integer, or a list -- whose elements may also be integers or other lists.": [
"nested-list-weight-sum",
[
"employee-importance",
"array-nesting",
"nested-list-weight-sum-ii"
],
[
"Depth-first Search"
]
],
"Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.": [
"moving-average-from-data-stream",
[],
[
"Design",
"Queue"
]
],
"Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds.Given a message and a timestamp (in seconds granularity), return true if the message should be printed in the given timestamp, otherwise returns false.It is possible that several messages arrive roughly at the same time.": [
"logger-rate-limiter",
[
"design-hit-counter"
],
[
"Hash Table",
"Design"
]
],
" Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as \"word\" contains only the following valid abbreviations:[\"word\", \"1ord\", \"w1rd\", \"wo1d\", \"wor1\", \"2rd\", \"w2d\", \"wo2\", \"1o1d\", \"1or1\", \"w1r1\", \"1o2\", \"2r1\", \"3d\", \"w3\", \"4\"] Notice that only the above abbreviations are valid abbreviations of the string \"word\". Any other string is not a valid abbreviation of \"word\".": [
"valid-word-abbreviation",
[
"word-abbreviation",
"minimum-unique-word-abbreviation"
],
[
"String"
]
],
"Given a sequence of words, check whether it forms a valid word square.A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 \u2264 k < max(numRows, numColumns).": [
"valid-word-square",
[
"toeplitz-matrix",
"word-squares"
],
[]
],
"Design and implement a data structure for a compressed string iterator. The given compressed string will be in the form of each letter followed by a positive integer representing the number of this letter existing in the original uncompressed string.Implement the\u00a0StringIterator class:next()\u00a0Returns the next character if the original string still has uncompressed characters, otherwise returns a white space.hasNext()\u00a0Returns true if\u00a0there is any letter needs to be uncompressed in the original string, otherwise returns false.\u00a0": [
"design-compressed-string-iterator",
[
"string-compression",
"lru-cache"
],
[
"Design"
]
],
" Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers a and b to be their absolute difference |a-b|. Your task is to find the maximum distance. ": [
"maximum-distance-in-arrays",
[],
[
"Array",
"Hash Table"
]
],
"Design a max stack that supports push, pop, top, peekMax and popMax.": [
"max-stack",
[
"min-stack"
],
[
"Design",
"Design"
]
],
"We can represent a\u00a0sentence as an array of words, for example, the\u00a0sentence \"I am happy with leetcode\" can be represented as arr = [\"I\",\"am\",happy\",\"with\",\"leetcode\"].Given two\u00a0sentences\u00a0sentence1 and\u00a0sentence2 each represented as a string array and given an array of string pairs similarPairs where\u00a0similarPairs[i] = [xi, yi]\u00a0indicates that the two words\u00a0xi and\u00a0yi are similar.Return true if\u00a0sentence1\u00a0and\u00a0sentence2\u00a0are similar, or false if they are not similar.Two sentences are similar if:They have the same length (i.e. the same number of words)sentence1[i] and\u00a0sentence2[i]\u00a0are similar.Notice that a word is always similar to itself, also notice that the similarity relation is not transitive. ": [
"sentence-similarity",
[],
[
"Hash Table"
]
],
"Given a set of keywords words and a string S, make all appearances of all keywords in S bold. Any letters between <b> and </b> tags become bold.The returned string should use the least number of tags possible, and of course the tags should form a valid combination.": [
"bold-words-in-string",
[],
[
"String"
]
],
" Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j. These lists A and B may contain duplicates. If there are multiple answers, output any of them. ": [
"find-anagram-mappings",
[],
[
"Hash Table"
]
],
"In the following, every capital letter represents some hexadecimal digit from 0 to f.The red-green-blue color \"#AABBCC\"\u00a0can be written\u00a0as\u00a0\"#ABC\" in\u00a0shorthand.\u00a0 ": [
"similar-rgb-color",
[],
[
"Math",
"String"
]
],
"Given a number N, return true if and only if it is a confusing number, which satisfies the following condition:We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid. A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid.\u00a0": [
"confusing-number",
[
"confusing-number-ii",
"strobogrammatic-number"
],
[
"Math"
]
],
"Given an array A of distinct integers sorted in ascending order, return the smallest index i that satisfies A[i] == i.\u00a0 Return -1 if no such i exists.\u00a0": [
"fixed-point",
[],
[
"Array",
"Binary Search"
]
],
"Given a text\u00a0string and words (a list of strings), return all index pairs [i, j] so that the substring text[i]...text[j]\u00a0is in the list of words.\u00a0": [
"index-pairs-of-a-string",
[],
[
"String",
"Trie"
]
],
"Given an array A of positive integers, let S be the sum of the digits of the minimal element of A.Return 0 if S is odd, otherwise return 1.\u00a0": [
"sum-of-digits-in-the-minimum-number",
[
"add-digits"
],
[
"Array"
]
],
"Given a list of scores of different students, return the average score of each student's top five scores in the order of each student's id.Each entry items[i]\u00a0has items[i][0] the student's id, and items[i][1] the student's score.\u00a0 The average score is calculated using integer division.\u00a0": [
"high-five",
[],
[
"Array",
"Hash Table",
"Sort"
]
],
"Given an array A of integers and\u00a0integer K, return the maximum S such that there exists i < j with A[i] + A[j] = S and S < K. If no i, j exist satisfying this equation, return -1.\u00a0": [
"two-sum-less-than-k",
[
"subarray-product-less-than-k",
"3sum-smaller",
"two-sum-ii-input-array-is-sorted",
"two-sum"
],
[
"Array"
]
],
"Given a year Y and a month M, return how many days there are in that month.\u00a0": [
"number-of-days-in-a-month",
[],
[]
],
"Given a string S, remove the vowels 'a', 'e', 'i', 'o', and 'u' from it, and return the new string.\u00a0": [
"remove-vowels-from-a-string",
[
"reverse-vowels-of-a-string"
],
[
"String"
]
],
"Given an array of integers A, return the largest integer that only occurs once.If no integer occurs once, return -1.\u00a0": [
"largest-unique-number",
[],
[
"Hash Table"
]
],
"The k-digit number N is an Armstrong number if and only if the k-th power of each digit sums to N.Given a positive integer N, return true if and only if it is an Armstrong number.\u00a0": [
"armstrong-number",
[],
[
"Math"
]
],
"Given an array nums sorted in non-decreasing order, and a number target, return True if and only if target is a majority element.A majority element is an element that appears more than N/2 times in an array of length N.\u00a0": [
"check-if-a-number-is-majority-element-in-a-sorted-array",
[
"majority-element-ii",
"majority-element"
],
[
"Array",
"Binary Search"
]
],
"There is a special keyboard with all keys in a single row.Given a string keyboard of length 26 indicating the layout of the keyboard (indexed from 0 to\u00a025), initially your finger is at index 0. To type a character, you have to move your finger to the index of the desired character. The time taken to move your finger from index i to index j is |i - j|.You want to type a string word. Write a function to calculate how much time it takes to type it with one finger.\u00a0": [
"single-row-keyboard",
[],
[
"String"
]
],
"A dieter consumes\u00a0calories[i]\u00a0calories on the i-th day.\u00a0Given an integer k, for every consecutive sequence of k days (calories[i], calories[i+1], ..., calories[i+k-1]\u00a0for all 0 <= i <= n-k), they look at T, the total calories consumed during that sequence of k days (calories[i] + calories[i+1] + ... + calories[i+k-1]):If T < lower, they performed poorly on their diet and lose 1 point;\u00a0If T > upper, they performed well on their diet and gain 1 point;Otherwise, they performed normally and there is no change in points.Initially, the dieter has zero points. Return the total number of points the dieter has after dieting for calories.length\u00a0days.": [
"diet-plan-performance",
[],
[
"Array",
"Sliding Window"
]
],
"Given a string S,\u00a0return the number of substrings that have\u00a0only one distinct letter.\u00a0": [
"count-substrings-with-only-one-distinct-letter",
[],
[
"Math",
"String"
]
],
"You have some apples, where arr[i] is the weight of the i-th apple.\u00a0 You also have a basket that can carry up to 5000 units of weight.Return the maximum number of apples you can put in the basket.\u00a0": [
"how-many-apples-can-you-put-into-the-basket",
[],
[
"Greedy"
]
],
"Given three integer arrays arr1, arr2 and arr3\u00a0sorted in strictly increasing order, return a sorted array of only\u00a0the\u00a0integers that appeared in all three arrays.\u00a0": [
"intersection-of-three-sorted-arrays",
[
"intersection-of-two-arrays"
],
[
"Hash Table",
"Two Pointers"
]
],
"In some array arr, the values were in arithmetic progression: the values\u00a0arr[i+1] - arr[i]\u00a0are all\u00a0equal for every\u00a00 <= i < arr.length - 1.Then, a value from arr\u00a0was removed that was\u00a0not the first or last value in the array.Return the removed value.\u00a0": [
"missing-number-in-arithmetic-progression",
[],
[
"Math"
]
],
"Given an initial array arr, every day you produce a new array using the array of the previous day.On the i-th day, you do the following operations on the array of day\u00a0i-1\u00a0to produce the array of day i:If an element is smaller than both its left neighbor and its right neighbor, then this element is incremented.If an element is bigger than both its left neighbor and its right neighbor, then this element is decremented.The first\u00a0and last elements never change.After some days, the array does not change. Return that final array.\u00a0": [
"array-transformation",
[],
[
"Array"
]
],
"A decimal number can be converted to its\u00a0Hexspeak representation\u00a0by first converting it to an uppercase hexadecimal string, then replacing all occurrences of the digit 0 with the letter O, and the digit 1 with the letter I.\u00a0 Such a representation\u00a0is valid\u00a0if and only if it consists only of the letters in the set {\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"I\", \"O\"}.Given a string num\u00a0representing a decimal integer N, return the Hexspeak representation of N if it is valid, otherwise return \"ERROR\".\u00a0": [
"hexspeak",
[],
[
"Math",
"String"
]
],
"Given an integer array arr, count how many elements\u00a0x\u00a0there are, such that x + 1 is also in arr.If there're duplicates in\u00a0arr, count them seperately.\u00a0": [
"counting-elements",
[],
[
"Array"
]
],
"You are given a string s\u00a0containing lowercase English letters, and a matrix\u00a0shift, where\u00a0shift[i] = [direction, amount]:direction\u00a0can be 0\u00a0(for left shift) or 1\u00a0(for right shift).\u00a0amount\u00a0is the amount by which string\u00a0s\u00a0is to be shifted.A left shift by 1 means remove the first character of s and append it to the end.Similarly, a right shift by 1 means remove the last character of s and add it to the beginning.Return the final string after all operations.\u00a0": [
"perform-string-shifts",
[],
[
"Array",
"Math"
]
],
"In a binary tree, a lonely node is a node that is the only child of its parent node. The root of the tree is not lonely because it does not have a parent node.Given the root of a binary tree, return an array containing the values of all lonely nodes in the tree. Return the list in any order.\u00a0": [
"find-all-the-lonely-nodes",
[
"univalued-binary-tree",
"binary-tree-tilt"
],
[
"Tree",
"Depth-first Search"
]
],
"Given the\u00a0head\u00a0of a linked list and two integers m and n. Traverse the linked list and remove some nodes\u00a0in the following way:Start with the head as the current node.Keep the first m nodes starting with the current node.Remove the next n nodesKeep repeating steps 2 and 3 until you reach the end of the list.Return the head of the modified list after removing the mentioned nodes.Follow up question: How can you solve this problem by modifying the list in-place?\u00a0": [
"delete-n-nodes-after-m-nodes-of-a-linked-list",
[],
[
"Linked List"
]
],
"Given the root of a binary tree, turn the tree upside down and return the new root.You can turn a binary tree upside down with the following steps:The original left child becomes the new root.The original root becomes the new right child.The original right child\u00a0becomes the new left child.The mentioned steps are done level by level, it is guaranteed that for each node in the given tree if this node has a right child then it also has a left child.\u00a0": [
"binary-tree-upside-down",
[
"reverse-linked-list"
],
[
"Tree"
]
],
"Given a string s , find the length of the longest substring\u00a0t\u00a0\u00a0that contains at most 2 distinct characters.": [
"longest-substring-with-at-most-two-distinct-characters",
[
"subarrays-with-k-different-integers",
"longest-substring-with-at-most-k-distinct-characters",
"sliding-window-maximum",
"longest-substring-without-repeating-characters"
],
[
"Hash Table",
"Two Pointers",
"String",
"Sliding Window"
]
],
"Given two strings s\u00a0and t, return true if they are both one edit distance apart, otherwise return false.A string s is said to be one distance apart from a string t if you can:Insert exactly one character into s\u00a0to get\u00a0t.Delete exactly one character from\u00a0s\u00a0to get\u00a0t.Replace exactly one character of\u00a0s\u00a0with a different character to get\u00a0t.\u00a0": [
"one-edit-distance",
[
"edit-distance"
],
[
"String"
]
],
"Given a sorted integer array nums, where the range of elements are in the inclusive range [lower, upper], return its missing ranges.": [
"missing-ranges",
[
"summary-ranges"
],
[
"Array"
]
],
"Given an input string\u00a0, reverse the string word by word.\u00a0": [
"reverse-words-in-a-string-ii",
[
"rotate-array",
"reverse-words-in-a-string"
],
[
"String"
]
],
"Design a class which receives a list of words in the constructor, and implements a method that takes two words word1 and word2 and return the shortest distance between these two words in the list. Your method will be called repeatedly many times with different parameters.\u00a0": [
"shortest-word-distance-ii",
[
"shortest-word-distance-iii",
"shortest-word-distance",
"merge-two-sorted-lists"
],
[
"Hash Table",
"Design"
]
],
"Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.word1 and word2 may be the same and they represent two individual words in the list.": [
"shortest-word-distance-iii",
[
"shortest-word-distance-ii",
"shortest-word-distance"
],
[
"Array"
]
],
"A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Find all strobogrammatic numbers that are of length = n.": [
"strobogrammatic-number-ii",
[
"strobogrammatic-number-iii",
"strobogrammatic-number"
],
[
"Math",
"Recursion"
]
],
"Given a string, we can \"shift\" each of its letter to its successive letter, for example: \"abc\" -> \"bcd\". We can keep \"shifting\" which forms the sequence:\"abc\" -> \"bcd\" -> ... -> \"xyz\"Given a list of non-empty strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.": [
"group-shifted-strings",
[
"group-anagrams"
],
[
"Hash Table",
"String"
]
],
"Given the root of a binary tree, return the number of uni-value subtrees.A uni-value subtree means all nodes of the subtree have the same value.\u00a0": [
"count-univalue-subtrees",
[
"longest-univalue-path",
"subtree-of-another-tree"
],
[
"Tree"
]
],
"Design and implement an iterator to flatten a 2d vector. It should support the following operations: next and hasNext.\u00a0": [
"flatten-2d-vector",
[
"flatten-nested-list-iterator",
"peeking-iterator",
"zigzag-iterator",
"binary-search-tree-iterator"
],
[
"Design"
]
],
"Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.": [
"meeting-rooms-ii",
[
"car-pooling",
"minimum-number-of-arrows-to-burst-balloons",
"meeting-rooms",
"merge-intervals"
],
[
"Heap",
"Greedy",
"Sort"
]
],
"Numbers can be regarded as product of its factors. ": [
"factor-combinations",
[
"combination-sum"
],
[
"Backtracking"
]
],
"Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.": [
"verify-preorder-sequence-in-binary-search-tree",
[
"binary-tree-preorder-traversal"
],
[
"Stack",
"Tree"
]
],
"Given an array of n integers nums and an integer\u00a0target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target.": [
"3sum-smaller",
[
"two-sum-less-than-k",
"valid-triangle-number",
"3sum-closest",
"3sum"
],
[
"Array",
"Two Pointers"
]
],
"Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.": [
"graph-valid-tree",
[
"number-of-connected-components-in-an-undirected-graph",
"course-schedule"
],
[
"Depth-first Search",
"Breadth-first Search",
"Union Find",
"Graph"
]
],
"Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.": [
"palindrome-permutation-ii",
[
"palindrome-permutation",
"permutations-ii",
"next-permutation"
],
[
"Backtracking"
]
],
"Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.Machine 1 (sender) has the function:string encode(vector<string> strs) { // ... your code return encoded_string; } Machine 2 (receiver) has the function: vector<string> decode(string s) { //... your code return strs; } So Machine 1 does:string encoded_string = encode(strs); and Machine 2 does:vector<string> strs2 = decode(encoded_string); strs2 in Machine 2 should be the same as strs in Machine 1.Implement the encode and decode methods.\u00a0": [
"encode-and-decode-strings",
[
"count-binary-substrings",
"string-compression",
"serialize-and-deserialize-binary-tree",
"count-and-say"
],
[
"String"
]
],
"": [
"search-in-rotated-sorted-array-ii",
[
"search-in-rotated-sorted-array"
],
[
"Array",
"Binary Search"
]
],
"Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3]....": [
"wiggle-sort",
[
"wiggle-sort-ii",
"sort-colors"
],
[
"Array",
"Sort"
]
],
"Given two 1d vectors, implement an iterator to return their elements alternately.\u00a0": [
"zigzag-iterator",
[
"flatten-nested-list-iterator",
"peeking-iterator",
"flatten-2d-vector",
"binary-search-tree-iterator"
],
[
"Design"
]
],
"Given a binary search tree and a node in it, find the in-order successor of that node in the BST.The successor of a node\u00a0p\u00a0is the node with the smallest key greater than\u00a0p.val.\u00a0": [
"inorder-successor-in-bst",
[
"inorder-successor-in-bst-ii",
"binary-search-tree-iterator",
"binary-tree-inorder-traversal"
],
[
"Tree"
]
],
"You are given a m x n 2D grid initialized with these three possible values.-1 - A wall or an obstacle.0 - A gate.INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647.Fill each empty room with the distance to its nearest gate. If it is impossible to reach a gate, it should be filled with INF.": [
"walls-and-gates",
[
"rotting-oranges",
"robot-room-cleaner",
"shortest-distance-from-all-buildings",
"number-of-islands",
"surrounded-regions"
],
[
"Breadth-first Search"
]
],
"An abbreviation of a word follows the form <first letter><number><last letter>. Below are some examples of word abbreviations:a) it --> it (no abbreviation) 1 \u2193 b) d|o|g --> d1g 1 1 1 1---5----0----5--8 \u2193 \u2193 \u2193 \u2193 \u2193 c) i|nternationalizatio|n --> i18n 1 1---5----0 \u00a0 \u2193 \u2193 \u2193 d) l|ocalizatio|n --> l10n Additionally for any string s of size less than or equal to 2 their abbreviation is the same string s. Find whether its abbreviation is unique in the dictionary. A word's abbreviation is called unique if any of the following conditions is met:There is no word in dictionary\u00a0such that their abbreviation is equal to the abbreviation of word.Else, for all words in dictionary such that their abbreviation is equal to the abbreviation of word\u00a0those words are equal to word.\u00a0": [
"unique-word-abbreviation",
[
"generalized-abbreviation",
"two-sum-iii-data-structure-design"
],
[
"Hash Table",
"Design"
]
],
"You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive \"++\" into \"--\". The game ends when a person can no longer make a move and therefore the other person will be the winner.Write a function to determine if the starting player can guarantee a win.": [
"flip-game-ii",
[
"can-i-win",
"guess-number-higher-or-lower-ii",
"flip-game",
"nim-game"
],
[
"Backtracking",
"Minimax"
]
],
"Given a binary tree, find the length of the longest consecutive sequence path.The path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The longest consecutive path need to be from parent to child (cannot be the reverse).": [
"binary-tree-longest-consecutive-sequence",
[
"binary-tree-longest-consecutive-sequence-ii",
"longest-consecutive-sequence"
],
[
"Tree"
]
],
"Given two sparse matrices A and B, return the result of AB.": [
"sparse-matrix-multiplication",
[],
[
"Hash Table"
]
],
"Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).If two nodes are in the same row and column, the order should be from left to right.": [
"binary-tree-vertical-order-traversal",
[
"binary-tree-level-order-traversal"
],
[
"Depth-first Search",
"Breadth-first Search"
]
],
"Write a function to generate the generalized abbreviations of a word.\u00a0": [
"generalized-abbreviation",
[
"minimum-unique-word-abbreviation",
"unique-word-abbreviation",
"subsets"
],
[
"Backtracking",
"Bit Manipulation"
]
],
"Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph.": [
"number-of-connected-components-in-an-undirected-graph",
[
"friend-circles",
"graph-valid-tree",
"number-of-islands"
],
[
"Depth-first Search",
"Breadth-first Search",
"Union Find",
"Graph"
]
],
"Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead.": [
"maximum-size-subarray-sum-equals-k",
[
"subarray-product-less-than-k",
"contiguous-array",
"range-sum-query-immutable",
"minimum-size-subarray-sum"
],
[
"Hash Table"
]
],
"Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it.": [
"largest-bst-subtree",
[],
[
"Tree"
]
],
"Design a Tic-tac-toe game that is played between two players on a n x n grid.": [
"design-tic-tac-toe",
[
"valid-tic-tac-toe-state"
],
[
"Design"
]
],
"Given an Android 3x3 key lock screen and two integers m and n, where 1 \u2264 m \u2264 n \u2264 9, count the total number of unlock patterns of the Android lock screen, which consist of minimum of m keys and maximum n keys.\u00a0Rules for a valid pattern:Each pattern must connect at least m keys and at most n keys.All the keys must be distinct.If the line connecting two consecutive keys in the pattern passes through any other keys, the other keys must have previously selected in the pattern. No jumps through non selected key is allowed.The order of keys used matters.\u00a0\u00a0Explanation:| 1 | 2 | 3 | | 4 | 5 | 6 | | 7 | 8 | 9 |Invalid move: 4 - 1 - 3 - 6 Line 1 - 3 passes through key 2 which had not been selected in the pattern.Invalid move: 4 - 1 - 9 - 2 Line 1 - 9 passes through key 5 which had not been selected in the pattern.Valid move: 2 - 4 - 1 - 3 - 6 Line 1 - 3 is valid because it passes through key 2, which had been selected in the patternValid move: 6 - 5 - 4 - 1 - 9 - 2 Line 1 - 9 is valid because it passes through key 5, which had been selected in the pattern.\u00a0": [
"android-unlock-patterns",
[],
[
"Dynamic Programming",
"Backtracking"
]
],
"Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game.The snake is initially positioned at the top left corner (0,0) with length = 1 unit.You are given a list of food's positions in row-column order. When a snake eats the food, its length and the game's score both increase by 1.Each food appears one by one on the screen. ": [
"design-snake-game",
[],
[
"Design",
"Queue"
]
],
"Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points symmetrically, in other words, answer whether or not if there exists a line that after reflecting all points over the given line the set of the original points is the same that the reflected ones.": [
"line-reflection",
[
"number-of-boomerangs",
"max-points-on-a-line"
],
[
"Hash Table",
"Math"
]
],
"Given a sorted array of integers nums and integer values a, b and c. Apply a quadratic function of the form f(x) = ax2 + bx + c to each element x in the array.The returned array must be in sorted order.Expected time complexity: O(n)": [
"sort-transformed-array",
[
"squares-of-a-sorted-array"
],
[
"Math",
"Two Pointers",
"Sort"
]
],
"Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb. The bomb kills all the enemies in the same row and column from the planted point until it hits the wall since the wall is too strong to be destroyed.": [
"bomb-enemy",
[],
[
"Dynamic Programming"
]
],
"Design a hit counter which counts the number of hits received in the past 5 minutes.Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made to the system in chronological order (ie, the timestamp is monotonically increasing). ": [
"design-hit-counter",
[
"logger-rate-limiter"
],
[
"Design"
]
],
"Given a nested list of integers, return the sum of all integers in the list weighted by their depth.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Different from the previous question where weight is increasing from root to leaf, now the weight is defined from bottom up. i.e., the leaf level integers have weight 1, and the root level integers have the largest weight.": [
"nested-list-weight-sum-ii",
[
"array-nesting",
"nested-list-weight-sum"
],
[
"Depth-first Search"
]
],
"Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty.\u00a0": [
"find-leaves-of-binary-tree",
[],
[
"Tree",
"Depth-first Search"
]
],
"Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer.": [
"plus-one-linked-list",
[
"plus-one"
],
[
"Linked List"
]
],
"Assume you have an array of length n initialized with all 0's and are given k update operations.Each operation is represented as a triplet: [startIndex, endIndex, inc] which increments each element of subarray A[startIndex ... endIndex] (startIndex and endIndex inclusive) with inc.Return the modified array after all k operations were executed.": [
"range-addition",
[
"range-addition-ii"
],
[
"Array"
]
],
"Design a Phone Directory which supports the following operations:\u00a0get: Provide a number which is not assigned to anyone.check: Check if a number is available or not.release: Recycle or release a number.\u00a0": [
"design-phone-directory",
[],
[
"Linked List",
"Design"
]
],
"Given a rows x cols screen and a sentence represented by a list of non-empty words, find how many times the given sentence can be fitted on the screen.": [
"sentence-screen-fitting",
[],
[
"Dynamic Programming"
]
],
"Convert a Binary Search Tree\u00a0to a sorted Circular Doubly-Linked List\u00a0in place.You can think of the left and right pointers as synonymous to the predecessor and successor pointers in a doubly-linked list. For a circular doubly linked list, the predecessor of the first element is the last element, and the successor of the last element is the first element.We want to do the transformation in place. After the transformation, the left pointer of the tree node should point to its predecessor, and the right pointer should point to its successor. You should return the pointer to the smallest element of the linked list.\u00a0": [
"convert-binary-search-tree-to-sorted-doubly-linked-list",
[
"binary-tree-inorder-traversal"
],
[
"Linked List",
"Divide and Conquer",
"Tree"
]
],
"Given a string representing arbitrarily nested ternary expressions, calculate the result of the expression. You can always assume that the given expression is valid and only consists of digits 0-9, ?, :, T and F (T and F represent True and False respectively).": [
"ternary-expression-parser",
[
"parse-lisp-expression",
"remove-comments",
"mini-parser"
],
[
"Stack",
"Depth-first Search"
]
],
"Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The org sequence is a permutation of the integers from 1 to n, with 1 \u2264 n \u2264 104. Reconstruction means building a shortest common supersequence of the sequences in seqs (i.e., a shortest sequence so that all sequences in seqs are subsequences of it). Determine whether there is only one sequence that can be reconstructed from seqs and it is the org sequence.\u00a0": [
"sequence-reconstruction",
[
"course-schedule-ii"
],
[
"Graph",
"Topological Sort"
]
],
"Given a list of points that form a polygon when joined sequentially, find if this polygon is convex (Convex polygon definition).\u00a0": [
"convex-polygon",
[],
[
"Math"
]
],
" By now, you are given a secret signature consisting of character 'D' and 'I'. 'D' represents a decreasing relationship between two numbers, 'I' represents an increasing relationship between two numbers. And our secret signature was constructed by a special integer array, which contains uniquely all the different number from 1 to n (n is the length of the secret signature plus 1). ": [
"find-permutation",
[],
[
"Greedy"
]
],
" Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most one 0. ": [
"max-consecutive-ones-ii",
[
"max-consecutive-ones-iii",
"max-consecutive-ones"
],
[
"Two Pointers"
]
],
"There is a ball in a maze with empty spaces (represented as 0) and walls (represented as 1). The ball can go through the empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.Given the maze, the ball's start position and\u00a0the destination, where start = [startrow, startcol] and destination\u00a0= [destinationrow, destinationcol], return true if the ball can stop at the destination, otherwise return false.": [
"the-maze",
[
"the-maze-ii",
"the-maze-iii"
],
[
"Depth-first Search",
"Breadth-first Search"
]
],
"There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.Given the ball's start position, the destination and the maze, find the shortest distance for the ball to stop at the destination. The distance is defined by the number of empty spaces traveled by the ball from the start position (excluded) to the destination (included). If the ball cannot stop at the destination, return -1.The maze is represented by a binary 2D array. 1 means the wall and 0 means the empty space. ": [
"the-maze-ii",
[
"the-maze-iii",
"the-maze"
],
[
"Depth-first Search",
"Breadth-first Search"
]
],
"Given a node in a binary search tree, find\u00a0the in-order successor of that node in the BST.If that node has no in-order successor, return\u00a0null.The successor of a node\u00a0is the node with the smallest key greater than node.val.You will have direct access to the node but not to the root of the tree. Each node will have a reference to its parent node.\u00a0Below is the definition for Node:class Node { public int val; public Node left; public Node right; public Node parent; } \u00a0": [
"inorder-successor-in-bst-ii",
[
"inorder-successor-in-bst"
],
[
"Tree"
]
],
"Given a picture consisting of black and white pixels, find the number of black lonely pixels.The picture is represented by a 2D char array consisting of 'B' and 'W', which means black and white pixels respectively. A black lonely pixel is character 'B' that located at a specific position where the same row and same column don't have any other black pixels.": [
"lonely-pixel-i",
[
"lonely-pixel-ii"
],
[
"Array",
"Depth-first Search"
]
],
"Given a picture consisting of black and white pixels, and a positive integer N, find the number of black pixels located at some specific row R and column C that align with all the following rules: Row R and column C both contain exactly N black pixels. For all rows that have a black pixel at column C, they should be exactly the same as row RThe picture is represented by a 2D char array consisting of 'B' and 'W', which means black and white pixels respectively. ": [
"lonely-pixel-ii",
[
"lonely-pixel-i"
],
[
"Array"
]
],
"You need to construct a binary tree from a string consisting of parenthesis and integers.The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parenthesis. The integer represents the root's value and a pair of parenthesis contains a child binary tree with the same structure.You always start to construct the left child node of the parent first if it exists.\u00a0": [
"construct-binary-tree-from-string",
[
"construct-string-from-binary-tree"
],
[
"String",
"Tree"
]
],
" During the NBA playoffs, we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the rank nth team, which is a good strategy to make the contest more interesting. Now, you're given n teams, you need to output their final contest matches in the form of a string. The n teams are given in the form of positive integers from 1 to n, which represents their initial rank. (Rank 1 is the strongest team and Rank n is the weakest team.) We'll use parentheses('(', ')') and commas(',') to represent the contest team pairing - parentheses('(' , ')') for pairing and commas(',') for partition. During the pairing process in each round, you always need to follow the strategy of making the rather strong one pair with the rather weak one.": [
"output-contest-matches",
[],