Practice Minimum Moves to Clean the Classroom
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Moves to Clean the Classroom
Problem Statement
In classroom, S is the start, L is litter, R restores energy to full capacity, X is an impassable obstacle, and . is empty space. Collecting litter empties that cell, and reset cells may be used repeatedly. Start at S with energy units. Each move to an in-bounds cardinal neighbor costs one unit. At zero energy, movement can continue only from an R cell, which restores the energy. Return the fewest moves needed to collect all litter, or -1 if impossible.
Source: Minimum Moves to Clean the Classroom on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
classroom = ["S.", "XL"], energy = 2
2
# Example 2
classroom = ["LS", "RL"], energy = 4
3
# Example 3
classroom = ["L.S", "RXL"], energy = 3
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Moves to Clean the Classroom.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.