# Need help in solving Range queries question :)

Hello coders,
I’m trying to understand how to solve questions in which :
we are given q queries and for each query, we are given a range [l,r]
and we have to transform the array in that range then find/do something in the changed array.

for example:
let’s take an array
and then input number of queries followed by type of queries
then if a query is of type : 1 subtract x to elements of the array in the range [l,r]
and if a query is of type : 2 count the element with the frequency of z in the range [l,r]

INPUT
a=[1,2,3,4,5];
q=4;
1 1 2 1 //type 1 query change array in range [1,2] by subtracting 3
2 4 //type 2 query find frequency of 4
1 3 4 2
2 3

OUTPUT
1
0

explanation :
after 1st query : 0 1 3 4 5
after 2st query : 1 //fequency of 4 is 1 in array
after 1st query : 0 1 1 2 5
after 1st query : 0 //frequency of 3 is 0

IF I am doing this for each query separately it is showing TLE

PS: I think it can be solved with mo’s but I am not getting how to implement these functions (for different types of transformations) quickly (without TLE) and then print when it is asked in the query.
please explain to me how to solve these types of questions and how to implement this MO’s algo.