Dated Jul 30, 2022;
last modified on Sat, 30 Jul 2022
Questions collected from sites like
LeetCode
.
While primarily used in the industry for interviewing candidates, I do
find them somewhat fun when done in a lower-pressure environment. Helps
me pick up some algorithmic techniques and refine my understanding.
Shortest Path in a Grid w/ Obstacles Elimination;
Minimizing Bottom-Right Paths in a 2xN Grid;
Queen's Movements on a Chessboard w/ Obstacles;
Spanning 4-Directional Walks From Origin to Destination w/ Obstacles;
Unique Paths to the Bottom-Right Corner w/ Obstacles;
Unique Paths to the Bottom-Right Corner;
Order Statistics K-th Smallest Element in Sorted Matrix Given an \(N \times N\) matrix, where each of the rows and columns are sorted in ascending order, return the \(k^{th}\) smallest element in the matrix. The memory complexity must be better than \(O(N^2)\).
It’s not guaranteed that matrix[r][c] > matrix[r-1][c], so we can’t compute the row (and similarly, the column) in which the \(k^{th}\) smallest element is in.
Using a priority queue that holds the \(K\) smallest elements does not work because the memory usage is \(O(K)\), where \(K\) can be any value in \([1, N^2]\)....