#3568
Minimum Moves to Clean the Classroom
expert · 1155 · lc medium +32 · 26.5% accepted · 126 likes · top 5%
Description
Grid classroom contains a start (\'S\'), litter (\'L\'), reset zones (\'R\'), obstacles (\'X\'), and open space (\'.\'). The student starts at \'S\' with energy points; each step costs 1. Reaching \'R\' refills energy to its max. Litter cells become empty once collected.
Return the minimum moves to collect all litter, or -1 if impossible.
Code
1
2
3