← All problemsSign in

Edit Distance on Grid

CodeChefRating 3530Open on judge ↗

Problem description. Recently, Chef is learning how to compute the edit distance between two strings. Today, Chef wants to generalize the concept of edit distance to 2D-grid(s). Given a 2D-grid with N rows and M columns, each cell of the grid is either white or black. There are three operations to change the grid: 1) Swap two cells share a common edge, which takes 1 second, or 2) Change one w

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start