原创 Inorder Successor in BST II
Given a node in a binary search tree, find the in-order successor of that node in the BST. If that node has no in-order
原创 Sorting (Merge Sort, Rainball Sort, quick select) 總結
Merge k Sorted Lists (這題是用PQ,或者merge sort都可以做,關於第K大的問題,參考: Find Kth 題目類型總結) Sort an Array (重點掌握merge sort和quick sort,因爲
原创 Math 題目總結
Math的題目,其實全是數學知識,沒有什麼太多的算法可言。 Sparse Matrix Multiplication (矩陣相乘就是所有的k,A(i,k) * B(k,j) = C(i,j) ,稀疏矩陣就是 有很多0,爲了提高速度也就是如
原创 記憶化搜索總結
Longest Increasing Path in a Matrix dp[i][j] 代表的是以i,j爲index的cell,最長的升序長度是多少。然後每個點做dfs,判斷四個方向的來的最大值;Time O(M*N) Space: O
原创 BFS 到 Level Order traverse 到 UnionFind 到 Topological Sort 到 Dijkstra 思路總結
BFS 找聯通量,找component. Number of Islands (BFS, DFS 都可以做) Surrounded Regions (BFS, DFS都可以做) Union Find 找聯通量是最合適的方法:對於動態加
原创 Maximum Points You Can Obtain from Cards
There are several cards arranged in a row, and each card has an associated number of points The points are given in the
原创 Maximum of Absolute Value Expression
Given two arrays of integers with equal lengths, return the maximum value of: |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]|
原创 Swap Adjacent in LR String
In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurre
原创 Android Unlock Patterns
Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock pa
原创 Bricks Falling When Hit
We have a grid of 1s and 0s; the 1s in a cell represent bricks. A brick will not drop if and only if it is directly co
原创 Most Stones Removed with Same Row or Column
On a 2D plane, we place stones at some integer coordinate points. Each coordinate point may have at most one stone. No
原创 Jump Game IV
Given an array of integers arr, you are initially positioned at the first index of the array. In one step you can jump
原创 Minimum Number of Taps to Open to Water a Garden
There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e The len
原创 Encode String with Shortest Length
Given a non-empty string, encode the string such that its encoded length is the shortest. The encoding rule is: k[encod
原创 Minimum Distance to Type a Word Using Two Fingers
You have a keyboard layout as shown above in the XY plane, where each English uppercase letter is located at some coor