<doocs>2055.Plates Between Candles_1.py
def platesBetweenCandles( s: str, queries: List[List[int]]) -> List[int]:
    n = len(s)
    presum = [0] * (n + 1)
    for i, c in enumerate(s):
        presum[i + 1] = presum[i] + (c == '*')
    
    left, right = [0] * n, [0] * n
    l = r = -1
    for i, c in enumerate(s):
        if c == '|':
            l = i
        left[i] = l
    for i in range(n - 1, -1, -1):
        if s[i] == '|':
            r = i
        right[i] = r
    
    ans = [0] * len(queries)
    for k, (l, r) in enumerate(queries):
        i, j = right[l], left[r]
        if i >= 0 and j >= 0 and i < j:
            ans[k] = presum[j] - presum[i + 1]
    return ans
def sample_funcname ( var_0 : str , var_2 : List [ List [ int ] ] ) -> List [ int ] :
    var_6 = len ( var_0 )
    var_9 = [ 0 ] * ( var_6 + 1 )
    for var_11 , var_12 in enumerate ( var_0 ) :
        var_9 [ var_11 + 1 ] = var_9 [ var_11 ] + ( var_12 == '*' )
    var_14 , var_15 = [ 0 ] * var_6 , [ 0 ] * var_6
    var_17 = var_16 = - 1
    for var_11 , var_12 in enumerate ( var_0 ) :
        if var_12 == '|' :
            var_17 = var_11
        var_14 [ var_11 ] = var_17
    for var_11 in range ( var_6 - 1 , - 1 , - 1 ) :
        if var_0 [ var_11 ] == '|' :
            var_16 = var_11
        var_15 [ var_11 ] = var_16
    var_20 = [ 0 ] * len ( var_2 )
    for var_21 , ( var_17 , var_16 ) in enumerate ( var_2 ) :
        var_11 , var_22 = var_15 [ var_17 ] , var_14 [ var_16 ]
        if var_11 >= 0 and var_22 >= 0 and var_11 < var_22 :
            var_20 [ var_21 ] = var_9 [ var_22 ] - var_9 [ var_11 + 1 ]
    return var_20
