AMAZON OA QUESTION
Anonymous User
692

You are given an array of Integers Arr. You are asked Q queries of two types:

1 i v. change Ith element of Arr to v
2 l r. Determine the count of integers that have an odd count in range of l to r

Task:

Foe every query of type 2,we have to tell the number of elements in the range from l to r with an odd count in that range

example-
n=4
arr=[1,2,3,2]
no of queries = 3
queries=[{2,1,3},{1,2,4},{2,1,4}]

descrpn- the first query is of type 2, elements 1,2,3 have an od count in the range [1,3]. so we answer 3
second query is of type 1, arr[1] is changed to 4. now arr=[1,4,3,2]
third query ,elements 1,4,3,2 have odd count in range [1,4], so answer is 4.

so we have to return answers of query type 2.

any ideas on how to approach this ?

Comments (1)