Imagine you're at an elegant dinner party where a long dining table is decorated with alternating plates and candles. You're given a string s where '*' represents a plate and '|' represents a candle.
Your task is to answer multiple queries efficiently. For each query [left, right], you need to count how many plates are properly positioned between candles within that substring range.
What makes a plate "between candles"?
A plate is considered between candles if there's at least one candle to its left AND at least one candle to its right within the given substring.
Example: For s = "||**||**|*" and query [3, 8], the substring is "*||**|". The two plates marked with ** in the middle are between candles, so the answer is 2.
Goal: Return an array where each element is the answer to the corresponding query.
Input & Output
Constraints
- 3 โค s.length โค 105
- s consists of '*' and '|' characters only
- 1 โค queries.length โค 105
- queries[i].length == 2
- 0 โค lefti โค righti < s.length