Minimum Water Tanks for Houses
Given a string representing houses ('H') and empty spaces ('-'), determine the minimum number of water tanks needed such that each house has a tank adjacent to it (left or right). Tanks can only be placed in empty spaces marked with '-'.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early February, 2026
Senior
Suppose you have an array of houses "-H-H-H", each house needs to be close to a water tank on either its left or right side. How many water tanks do you need? Water Tanks can only go where there is a dash. Ex. "-H-H-H" -> solution: 2 tanks needed, one option is '-HTHTH', or 'TH-HTH'
Hello Interview Premium
Your account is free and you can post anonymously if you choose.