stratascratch 2054: Consecutive Days
stratascratch 2054 Consecutive Days Intuition & Approach The question requires to write a sql query to find any user who has 3 consecutive days with activity. Step 1: Simple Intutive Solutio...
stratascratch 2054 Consecutive Days Intuition & Approach The question requires to write a sql query to find any user who has 3 consecutive days with activity. Step 1: Simple Intutive Solutio...
LeetCode 3830 Longest Alternating Subarray After Removing At Most One Element Intuition & Approach Step 1: Subproblem What is the purpose of this problem? increase, decrease, increase, decre...
Continuous Distributions Basic Definitions PDF ($f(x)$): \(P(X \in B) = \int_B f(x)dx, \quad P(a \le X \le b) = \int_a^b f(x)dx\) Properties: $f(x) \ge 0$ and $\int_{-\infty}^{\infty} f(x)dx = 1$...
Leetcode 2435. Paths in Matrix Whose Sum Is Divisible by K Intuition Step1: subproblem. This can be 3D DP: $DP[i][j][k]$ indicate the #(routes) from $[0,0]$ to $[i,j]$ with value k. Then the goa...
Leetcode contest I took Leetcode contest yesterday, Biweekly 168 and Weekly 473. I solve 3 in Biweekly and 2 in Weekly, and I get TLE/MLE on rest questions. At least, I got bad idea, it’s much b...
I will give all examples in ascending order, just change the judgement clause when you need descending order. $O(n^2)$ sorting algorithms Selection Sort The idea is, always select the smallest v...
LeetCode Problems 208. Implement Trie (Prefix Tree) 211. Design Add and Search Words Data Structure 212. Word Search II In previous problem, you should use DFS instead of BFS, or you will TLE. ...
Example 1 Never write: [[0] * 5] * 10 this clause you can only use once, [0] * 5, like this. But if you use [[0] * 5] * 10 instead of [[0]*5 for _ in range(10)], that will make your variable sh...
Very short conclusion: at least two traversal can uniquely a tree from the traversal, and one must be inorder traversal.