The problem is :
Given an Array A consisting of N positive integers, you have to answer Q queries on it. Queries can be of the two types: * 1 X Y - Update X at location Y in the array. * 2 L R - Print the sum of range [L, R], i.e. Both L and R are inclusive.
Input
SolutionGiven an Array A consisting of N positive integers, you have to answer Q queries on it. Queries can be of the two types: * 1 X Y - Update X at location Y in the array. * 2 L R - Print the sum of range [L, R], i.e. Both L and R are inclusive.
Input
5 5 2 3 4 8 9 1 0 3 2 0 1 2 0 4 1 2 5 2 0 3
Output
6 27 19
x,y=map(int, input().split())
ar=list(map(int, input().split()))
i=0
while i<y:
p,q,r=map(int, input().split())
sum = 0
if p==1:
ar[q]=r
else :
for x in range(q,r+1):
sum=sum+ar[x]
print (sum)
i=i+1
if you have any problem in this code, take a screenshot and contact with Rishabh Chaubey.