#K63972. Process Array Queries
Process Array Queries
Process Array Queries
You are given an array of integers of length (n) and required to process (q) queries on the array. There are two types of queries:
1 l r k: Count the number of occurrences of integer (k) in the subarray from index (l) to (r) (inclusive).
2 i x: Update the element at index (i) to (x).
For each query of type 1, output the result on a new line. Note: Array indices are 1-based. The problem requires using standard input/output (stdin/stdout).
inputFormat
The input is read from stdin and follows this format:
- The first line contains two integers (n) and (q) indicating the size of the array and the number of queries.
- The second line contains (n) space-separated integers representing the initial array.
- Each of the next (q) lines contains a query in one of the following formats:
- For a count query:
1 l r k
- For an update query:
2 i x
- For a count query:
outputFormat
For each query of type 1, output a single integer representing the count of (k) in the specified subarray. Each result should be printed on a new line to stdout.## sample
1 1
1
1 1 1 1
1
</p>