Competitive Programming Playground

Interactive algorithm visualizations for competitive programming problems.

BFS Order

Visualize BFS traversal order on a 2D grid starting from (0,0).

Booth's Algorithm

Find the minimal rotation of a circular string in O(n) time.

Cyclic Array Partitioning

Divide circular array into minimal segments with bounded sum using prefix sums and binary search.

Cross Product

Classify points as left, right, or on a directed line segment using cross products.

Convex Hull

Find the outermost layer of points forming a convex polygon using Andrew's monotone chain.

Point in Polygon

Classify a query point as inside, outside, or on the boundary of a polygon using ray casting.

Lattice Points

Count interior and boundary lattice points of a polygon using Pick's theorem.

Lebah Pekerja

Count subordinates for each employee in a company hierarchy using DFS subtree sizes.

Pesta Buah

Check if party guests can be split into two groups with no enemies in the same group (bipartite graph).

Rute Rahasia

Detect cycles in an undirected graph using DFS with 3-color marking.

Gua Bawah Tanah

Find the longest path (diameter) in a tree using double BFS.

Resep Kuno

Compute minimum edit distance between two strings using Levenshtein DP.

Pabrik Madu

Find minimum production time using binary search on machine scheduling.

Pembagian Toples

Split array into k groups minimizing maximum sum via binary search + greedy.

Labirin Bawah Tanah

Count grid paths avoiding traps with DP (mod 10^9+7).

Jarak Terowongan

Answer distance queries on a tree structure using BFS depth + LCA.

Festival Film

Maximize movies watched by k members using greedy interval scheduling.

Peta Hutan

Count trees in rectangular areas using 2D prefix sums.

Terowongan Kedua

Find second minimum spanning tree cost via Kruskal + edge enumeration.

Komponen Kota

Track connected components and max size after each edge addition (DSU).

Peri Gunung

Find minimum fairies to light all mountain valleys using line-of-sight geometry.

Saklar Lampu

Lights Out puzzle — toggle switches to turn all lamps on with minimum clicks.