Tap here to switch tabs
Problem
Submissions

Problem: Plates Between Candles

med
30 min
Try to solve the Plates Between Candles problem.

Statement

Given a string s where each character is either a plate '*' or a candle '|', and a 22D integer array queries where queries[i] = [ left_i , right_i ] represents the substring s[left_i...right_i] inclusive.

For each query, determine the number of plates that are situated between two candles within the specified substring. A plate is considered between candles if there exists at least one candle to its left and at least one candle to its right within the substring boundaries.

Return an integer array answer where answer[i] is the solution to the ith query.

Constraints:

  • 3≤3 \leq s.length ≤105\leq 10^5

  • s consists of '*' and '|' characters.

  • 1≤1 \leq queries.length ≤105\leq 10^5

  • queries[i].length =2= 2

  • 0≤0 \leq left_i ≤\leq right_i << s.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Plates Between Candles

med
30 min
Try to solve the Plates Between Candles problem.

Statement

Given a string s where each character is either a plate '*' or a candle '|', and a 22D integer array queries where queries[i] = [ left_i , right_i ] represents the substring s[left_i...right_i] inclusive.

For each query, determine the number of plates that are situated between two candles within the specified substring. A plate is considered between candles if there exists at least one candle to its left and at least one candle to its right within the substring boundaries.

Return an integer array answer where answer[i] is the solution to the ith query.

Constraints:

  • 3≤3 \leq s.length ≤105\leq 10^5

  • s consists of '*' and '|' characters.

  • 1≤1 \leq queries.length ≤105\leq 10^5

  • queries[i].length =2= 2

  • 0≤0 \leq left_i ≤\leq right_i << s.length