human
Range sum queries for anticlockwise rotations of Array by K indices | Function to execute the queries.
Construct a new array of size 2 * N to store prefix sum of every index.
Copy elements to the new array.
Calculate the prefix sum for every index.
Set start pointer as 0.
Query to perform anticlockwise rotation.
Query to answer range sum.
If pointing to 1 st index.
Display the sum upto start + R.
Subtract sum upto start + L - 1 from sum upto start + R.
Driver code.
Number of query.
Store all the queries"
Solution in Python:
 ... Can you provide a code to range sum queries for anticlockwise rotations of Array by K indices and the other steps required?
assistant
#Here is code to range sum queries for anticlockwise rotations of Array by K indices and the other steps required.
 def rotatedSumQuery ( arr , n , query , Q ) :
	prefix = [ 0 ] * ( 2 * n )
	for i in range ( n ) :
		prefix [ i ] = arr [ i ]
		prefix [ i + n ] = arr [ i ]
	for i in range ( 1 , 2 * n ) :
		prefix [ i ] += prefix [ i - 1 ] ;
	start = 0 ;
	for q in range ( Q ) :
		if ( query [ q ] [ 0 ] == 1 ) :
			k = query [ q ] [ 1 ]
			start = ( start + k ) % n ;
		elif ( query [ q ] [ 0 ] == 2 ) :
			L = query [ q ] [ 1 ]
			R = query [ q ] [ 2 ]
			if ( start + L == 0 ) :
				print ( prefix [ start + R ] )
			else :
				print ( prefix [ start + R ] - prefix [ start + L - 1 ] )
arr = [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
Q = 5
query = [ [ 2 , 1 , 3 ] , [ 1 , 3 ] , [ 2 , 0 , 3 ] , [ 1 , 4 ] , [ 2 , 3 , 5 ] ]
n = len ( arr ) ;
rotatedSumQuery ( arr , n , query , Q ) ;