Practice Minimum Number of Food Buckets to Feed the Hamsters
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#2086
LeetCode ProblemMinimum Number of Food Buckets to Feed the Hamsters
Problem Statement
H marks a hamster and . an empty position. Place buckets only in empty positions. Each hamster needs a bucket in at least one immediately adjacent position; one bucket can serve both neighbors. Return the minimum buckets needed, or -1 if impossible.
Source: Minimum Number of Food Buckets to Feed the Hamsters on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
hamsters = "H..H"
Output
2
# Example 2
Input
hamsters = ".H.H."
Output
1
# Example 3
Input
hamsters = ".HHH."
Output
-1
Constraints
1 <= hamsters.length <= 10^5
hamsters[i] is either'H' or '.'.
Related LeetCode Problems
Practice more problems similar to Minimum Number of Food Buckets to Feed the Hamsters.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.