TODO
Top Current: ELF Immediate: Writing an ELF manually Stack For I have so little time.
Top Current: ELF Immediate: Writing an ELF manually Stack For I have so little time.
This is a list of problems with deceptively simple solutions, all that I might’ve either completely missed or arrived at via a contrived way losing the essence and intuition of it.
I’m really disheartened today.
string hashing core idea.
Bitmask DP Considerations? Do I iterate over set bits and remove them? Is optimal structure a vine Do I iterate over submasks and remove them? Is optimal structure a tree Think bitmask dp, when iterating over permutations of processing order would works.
Digit DP Typical state: position, tight bound, leading-zero state, and the problem-specific state.
Knapsack Fractional knapsack greedy, sort items by value/wt and pick max ones 0/1 Knapsack - O(nw) time and O(nw) space variant def: f(w) ⇒ max value s.t.
Dynamic Programming Dice Combinations way to make sum n by using a(i) repeatedly → what is f? defn: f(i) = no of throws to make i base: f(⇐0) = 1 trans: f(i) = sum over throw in 1..6 : f(i-throw) Min Coins min number of a(i) needed ( rep ) to make sum n Problem is framed as coins def: min no of coin...
CSES Graph Problems Graphs Aim here is to implement whatever multiple approaches and use this as reference for programming style for future.
Trees Company Queries // problem: go up k levels // tag: bin lift #include <bits/stdc++.h> using namespace std; int main() { #define int long long int n, q; cin >> n >> q; vector<vector<int>> g(n + 1); for (int i = 2; i <= n; i++) { int u; cin >> u; g[u].push_b...