Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C 81 Problem statement: Given a string s consisting of stars and bars I,an array of starting indices starIndex,and an array of ending indices endIndex,determine
C 81 Problem statement: Given a string s consisting of stars and bars "I",an array of starting indices starIndex,and an array of ending indices endIndex,determine the number of stars between any two bars within the substrings between the two indices inclusive. NOTE that in this problem indexing starts at 1. . A Star is represented as an asterisk [*=ascii decimal 42] A Bar is represented as a Pipe ["I"-ascii decimal 124] Example: s="/**1*1' startindex=[1,1] endindex=[5,6] For the first pair of indices (1,5) the substrings is "***". There are 2 stars between a pair of bars For the second pair of indices (1,6) the substring is "***" and there are 2+1=3 stars in between the bars. Both of the answers are returned to the array [2,3]. Constraints: int [n];each element[i] answers the query of startIndex[i] to endindex[i] Constraints 1<=n<=105 1<-StartInde[i]<-endIndex[i] Each Character of s is either *** or "1" >Input Format for Custom testing
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started