DSA/CP problems

Found my old codeforces code templates

Kosaraju Variants

Kosaraju's algorithm finds all strongly connected components in a directed graph in O(V + E) time using two DFS passes: first to order nodes by finish time, then on the reversed graph to identify each SCC.

25-01-2025graph · scc · kosaraju · dfs

Knuth-Morris-Pratt (KMP) String Matching

KMP algorithm efficiently finds all occurrences of a pattern in text in O(n + m) time by using a failure table to avoid redundant comparisons when mismatches occur.

24-01-2025string-matching

Fenwick Trees

Fenwick Trees enable efficient range sum queries and point updates in O(log n) time by storing partial sums based on binary index patterns.

22-01-2025fenwick-tree · prefix-sums · range-queries