~/problems

Problems

Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.

Tree techniques

Euler tour of a tree

Flatten subtrees into contiguous ranges with tin/tout.

Notes

Recognise it when: you need subtree queries or updates. Flatten the tree so every subtree is a contiguous range.

A DFS assigns tin[v] on entry and tout[v] after the children. The subtree of v is exactly [tin[v], tout[v]), and range structures (Fenwick or segment tree) then answer subtree sums.

Gotchas: use an iterative DFS for deep trees.

4 problems

Advanced & competitive

Tree techniques Binary lifting, LCA, Euler tours.

Euler tour of a tree

esc