Pergunta de entrevista da empresa Google

Question about valid parentheses in a string, about possible string permutations. The hardest as for me was about an interval and water drops, which fall on it. I had to count how many of them are needed to make the interval wet.