Counting Stars Between Pipes In A String
Count Stars Between Pipes: Given a string s and ranges a, count stars enclosed between first & last pipes for each range. Use prefix & suffix arrays to find nearest pipes & calculate star counts.
Problem Statement: Count Stars Between Pipes
Problem Description
You are given a string s consisting of two types of characters:
Pipes ('|'), representing dividers.
Stars ('*'), representing items.
Additionally, you are given a list of ranges a, where each range is represented as an array [i, j]. For each range, you need to count the number of stars ('*') that are enclosed between the first and last pipes within the range.
If there are no valid pairs of pipes within a range, the result for that range should be 0.
Input
String s: A non-empty string containing only the ch...