With pipe 2 closed, pipe 1 will fill the water tank in 1 hour.
With pipe 1 closed, pipe 2 will empty the water tank in 2 hours.
If both pipes are open, how long will it take for the water tank to fill ?
Rate for pipe 1 1 tank/1hour = 1
Rate for pipe 2 1 tank/2 hours = 1/2
1 tank / (1 tank / hour - 1/2 tank/hour) = 1 tank /(1/2 tank/hour) = 2 hours (edited...misread the Q)