Find minimum tanks to cover all houses
Company: Palo
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates a candidate's proficiency in algorithm design, specifically greedy strategies and string/array manipulation for coverage and optimization under local adjacency constraints.
Constraints
- S contains H and -
Examples
Input: ('-H-HH--',)
Expected Output: 2
Explanation: Prompt-style example.
Input: ('H',)
Expected Output: -1
Explanation: Impossible.
Input: ('H-',)
Expected Output: 1
Explanation: One tank to the right.
Input: ('-H--H',)
Expected Output: 2
Explanation: Greedy right placement.
Hints
- Scan left to right; prefer placing a tank to the right to cover possible future houses.