This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Combination.py | |
https://leetcode.com/problemset/all/?search=Combination%20Sum | |
candidates without duplicates: 39 / | |
78 sub sets / 254. Factor Combinations | |
candidates with duplicates: 40 / 267. Palindrome Permutation II | |
combinations of k numbers: 216 | |
output number of possible combinations: 377 | |
others: 10. Regular Expression Matching / 294. Flip Game II / 291. Word Pattern II / 51. N-Queens /52. N-Queens II / 351. Android Unlock Patterns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Structured Query Language(SQL) | |
*basic | |
. JOIN | |
FROM table1 JOIN table2 ON table1.col= table1.col | |
INNER: at least one match of rows | |
LEFT: match left table rows | |
RIGHT: match right table rows | |
FULL: matching rows in both tables | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Correlation | |
https://en.wikipedia.org/wiki/Correlation_coefficient | |
+1 strongest possible agreement | |
0 two varaible are independent | |
−1 strongest possible disagreement | |
r(x,y)= cov(x,y)/(var(x)*var(y))**.5 | |
---cov(x,y)= E( (x-u)(y-u) ) | |
---var(x) var= (E(x-u)**2 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Depth | |
1 maximun depth: 104 | |
104. Maximum Depth of Binary Tree | |
https://leetcode.com/problems/maximum-depth-of-binary-tree/description/ | |
class Solution { | |
public int maxDepth(TreeNode root) { | |
//O(N) | |
if(root==null) return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merge: 617 | |
trim: 669 | |
617. Merge Two Binary Trees | |
https://leetcode.com/problems/merge-two-binary-trees/description/ | |
Example 1: | |
Input: | |
Tree 1 Tree 2 | |
1 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Level Order Traversal: 102 / 107 / 637 | |
/582 | |
102. Binary Tree Level Order Traversal | |
https://leetcode.com/problems/binary-tree-level-order-traversal/description/ | |
Given binary tree [3,9,20,null,null,15,7], | |
3 | |
/ \ | |
9 20 | |
/ \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Separate chaining | |
linked lists of values | |
* search time complexity: logn | |
2. Open addressing | |
Insert(k): Keep probing until an empty slot is found. Once an empty slot is found, insert k. | |
Search(k): Keep probing until slot’s key doesn’t become equal to k or an empty slot is reached. | |
* linear probing | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
973. K Closest Points to Origin | |
https://leetcode.com/problems/k-closest-points-to-origin/ | |
We have a list of points on the plane. Find the K closest points to the origin (0, 0). | |
(Here, the distance between two points on a plane is the Euclidean distance.) | |
You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in.) | |
Example 1: | |
Input: points = [[1,3],[-2,2]], K = 1 | |
Output: [[-2,2]] | |
Explanation: | |
The distance between (1, 3) and the origin is sqrt(10). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
237. Delete Node in a Linked List | |
https://leetcode.com/problems/delete-node-in-a-linked-list/description/ | |
class Solution(object): | |
def deleteNode(self, node): | |
""" | |
:type node: ListNode | |
:rtype: void Do not return anything, modify node in-place instead. | |
""" | |
if not node: return | |
node.val= node.next.val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
516. Longest Palindromic Subsequence | |
https://leetcode.com/problems/longest-palindromic-subsequence/ | |
https://www.youtube.com/watch?v=v8irqkTcJ6s | |
Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000. | |
Example 1: | |
Input: | |
"bbbab" | |
Output: | |
4 | |
One possible longest palindromic subsequence is "bbbb". |
OlderNewer