How to solve this?
Anonymous User
111

Anyone can solve this
Gon is currently standing in a market andthere are different shops to left and right direction as well as where he is intially standing. He choose to walk as per instructions given string s of n leng if s[i] = L he walks left by 1 step and if R then walk right by 1 step and visit a shop. You are also given two array of len m u, v and u[i] <= v[i] for all i in both array. Return array whose i th element contains answer to the ith query wherein query is as follows:
if gon doesn't walk at all as described in the string s for all steps from index u[i] to v[i] (1 based indexing) then how many distinct shop visited at all.

first line string s
second line m
next m line array element of u
next line integer m
next m line array element of v
Input:
'LRLLRLLR'
2
1
2
2
8
8
Output: 1
2

Explan: ans to first query where u[0] = 1 and v[0] = 8 he is only able to visit 1 shop since he dosen't visit at all
second query u[1] = 2 v[1] = 8 he able to visit one shop he is at intially and one to left so ans will be 2

Comments (0)