- Math: Geometric Sequences
- Python: List (
enumarate), Dict (keys(),values(),items()) - LeetCode: 50. Pow(x, n): using Recursive with
Pow(x,n) = Pow(x,n//2), rmb for n = odd and even cases
- Math: Modular Arithmetic
- Congruence
a ≡ b (mod n)For a positive integer n, the integers a and b are congruent mod n if their remainders when divided by n are the same.- For example: 52≡24(mod7): 52 and 24 are congruent (mod 7) because (52 mod 7) = 3 and (24 mod 7) = 3.
- Properties of multiplication in Modular Arithmetic:
(a mod n) mod n = a mod n: This is obvious because a mod n ∈ [0,𝑛−1] and so the second modmod cannot have an effect.(A^2) mod C = (A * A) mod C = ((A mod C) * (A mod C)) mod C
- Congruence
- LeetCode: Fast Exponentiation
- Python:
- Nested List Comprehension
[[item if not item.isspace() else -1 for item in row] for row in board]to build 2D matrix - String Formatting with Padding 0: For example, convert integer 2 to "02"
f"{month:02d}" - Math's Ceil & Floor:
math.ceil(),math.floor()
- Nested List Comprehension
- Math:
Modular Multiplicative Inverse (MMI): MMI(a, b) = x s.ta*x ≡ 1 (mod n)- For example: a = 3, m = 11 => x = 4 as (3*4) mod 11 = 1
Euclidean Algorithmto find GCD of A & B &Extended Euclidean Algorithmto find MMI(A, B)
- LeetCode:
Best Time to Buy and Sell Stock(Keep track on the buying price, compare to the next days),Climbing Stairs(At T(n): first step = 1, remaining steps = T(n-1) or first step = 2, remaing steps = T(n-2). This recurrence relationship is similar to Fibonacci number)
- LeetCode:
3 Sum,Longest Palindromic SubstringandContainer With Most Water
- LeetCode:
Number of Islands,Design Circular Queue
- Data Science: Understand about confusion matrix of classifier, Precision & Recall, F1