Competitive Programming Editorials

Stop Reading.
Start Seeing.

Constructive turns competitive programming editorials into interactive, step-by-step visualizations so the solution actually clicks.

Browse Editorials
solve.cpp
1for i in range(1, n+1):
2 for j in range(1, W+1):
3 if w[i-1] <= j:
4 dp[i][j] = max(
5 dp[i-1][j],
6 dp[i-1][j-w[i-1]] + v[i-1]
7 )
8 else:
9 dp[i][j] = dp[i-1][j]
Memory Inspector
w=0w=1w=2w=3w=4w=5
i=0
0
0
0
0
0
0
i=1
0
1
1
1
1
1
i=2
0
1
1
2
2
2
i=3
0
1
1
2
2
3
i=4
0
1
2
2
3
3

Insight: At dp[3][5], we compare the previous best (2) vs taking item 3. Taking it yields 3, which wins.

Why Constructive

Editorials that actually teach you something.

Algorithm Visualization

Watch DP tables fill, graphs traverse, and arrays sort — synchronized with the exact line of code that drives each step.

?→!

The Aha Moment

We walk you through the reasoning — the leap from brute force to the elegant solution — so you can reproduce it on new problems.

Problem First

Each editorial starts with the problem statement and key observations — building context before jumping into code.

LaTeX & Math

Full KaTeX support for recurrences, proofs, and complexity analysis — rendered beautifully inline.

dp[i][j]=max⁡(dp[i−1][j],dp[i−1][j−wi−1]+vi−1)dp[i][j] = \max( dp[i-1][j], dp[i-1][j-w_{i-1}] + v_{i-1} )

Master the patterns behind the hardest problems

Dynamic Programming
Graph Theory
Trees
Greedy Algorithms
String Matching
Number Theory
Binary Search
Two Pointers
Bit Manipulation
Segment Trees
Trie
Geometry

Ready to see algorithms differently?

Explore our growing library of visualized editorials — from knapsack to segment trees.

Get Started