← All problemsSign in

Make Matrix Empty

An $N X N$ square matrix containing randomly arranged numbers ranging from $0$ to $K$ are given (numbers may repeat). The matrix can be made as empty as possible using one of the following rules at each step. a) A consecutive sequence of duplicate numbers can be removed along vertical line or horizontal line. b) A number can move to neighboring left or right or top or bottom empty position. Here

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