Monday, March 9, 2020

Interview Questions

Counting sort




(diagram gives the impression of DAG, but it's DG => Directed and cyclic, find the shortest path from source to all)
non heap approach as well

Interval merging/intersection/Task Scheduling
31. https://leetcode.com/problems/task-scheduler/

32. https://leetcode.com/problems/non-overlapping-intervals/ - sort by end time ascending, maximize number of tasks finished
33. https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons - same as above, sort by end time

34. https://leetcode.com/problems/interval-list-intersections/
35. https://leetcode.com/problems/merge-intervals/ - start time ascending sort, keep merging with top of the stack
36. https://leetcode.com/problems/meeting-rooms/

These 4 problems have exact same solution:
37. https://leetcode.com/problems/meeting-rooms-ii/
38. https://leetcode.com/problems/my-calendar-i/
39. https://leetcode.com/problems/my-calendar-ii/
40. https://leetcode.com/problems/my-calendar-iii/

41. https://leetcode.com/problems/data-stream-as-disjoint-intervals/

Binary Tree/Binary Search Tree
https://leetcode.com/problems/binary-tree-coloring-game/

42. Inorder Traversal => https://leetcode.com/problems/binary-search-tree-iterator/
43. Inorder Traversal => https://leetcode.com/problems/validate-binary-search-tree/
44. InOrder => https://leetcode.com/problems/kth-smallest-element-in-a-bst
45. InOrder => https://leetcode.com/problems/increasing-order-search-tree
46. PostOrder => https://leetcode.com/problems/serialize-and-deserialize-binary-tree/
47. PostOrder => https://leetcode.com/problems/range-sum-of-bst/
48. PostOrder => https://leetcode.com/problems/flatten-binary-tree-to-linked-list
49. DFS (backtracking) https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/
50. DFS => https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves
51. DFS https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/
52. BFS => https://leetcode.com/problems/check-completeness-of-a-binary-tree/
53. BFS => https://leetcode.com/problems/binary-tree-right-side-view/
54. https://leetcode.com/problems/binary-tree-vertical-order-traversal/
55. https://leetcode.com/problems/closest-binary-search-tree-value/
56. https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/
57. https://leetcode.com/problems/minimum-depth-of-binary-tree/
58. https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/
59. https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii/
60. https://leetcode.com/problems/split-bst/
61. https://leetcode.com/problems/populating-next-right-pointers-in-each-node
62. https://leetcode.com/problems/univalued-binary-tree
63. https://leetcode.com/problems/diameter-of-binary-tree

Binary Search
64. https://leetcode.com/problems/missing-element-in-sorted-array/
65. https://leetcode.com/problems/random-pick-with-weight/
66. https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
67. https://leetcode.com/problems/first-bad-version/
68. https://leetcode.com/problems/fixed-point/
69. https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix
https://leetcode.com/problems/shortest-way-to-form-string/

DP
78. https://leetcode.com/problems/partition-equal-subset-sum
79. https://leetcode.com/problems/minimum-cost-for-tickets/
80. https://leetcode.com/problems/longest-arithmetic-sequence/
81. https://leetcode.com/problems/decode-ways/
82. https://leetcode.com/problems/minimum-knight-moves/
83. https://leetcode.com/problems/target-sum/
84. https://leetcode.com/problems/maximal-square
85. https://leetcode.com/problems/word-break/
86. https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix
87. https://leetcode.com/problems/knight-probability-in-chessboard/
88. https://leetcode.com/problems/valid-palindrome-iii/
89. https://leetcode.com/problems/longest-palindromic-subsequence
90. https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/
https://leetcode.com/problems/perfect-squares/
https://leetcode.com/problems/campus-bikes-ii/
https://leetcode.com/problems/cherry-pickup-ii/
https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers/
https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing/
https://leetcode.com/problems/odd-even-jump/
https://leetcode.com/problems/count-square-submatrices-with-all-ones/

https://leetcode.com/problems/wiggle-sort/

Deep Copy
105. https://leetcode.com/problems/clone-graph/
106. https://leetcode.com/problems/copy-list-with-random-pointer/

Arithmetic operations/Math
107. https://leetcode.com/problems/multiply-strings/
108. https://leetcode.com/problems/divide-two-integers/ (Read the Solution section, quite good)
109. https://leetcode.com/problems/bulb-switcher/
110. https://leetcode.com/problems/fraction-to-recurring-decimal/
111. https://leetcode.com/problems/basic-calculator-ii/
112. Geometry => https://leetcode.com/problems/minimum-area-rectangle
113. https://leetcode.com/problems/largest-number/
114. https://leetcode.com/problems/projection-area-of-3d-shapes/
115. https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero
116. https://leetcode.com/problems/plus-one/


No comments:

Blog Archive