Given an array of N numbers nums and Q queries to perform, queries are one of the two types:
1 l r s e means performing nine's complement for the [e-th, ..., s+1-th, s-th] digits of [nums_l, nums_(l+1), ..., nums_e]
2 l r s e means printing the sum of the [e-th, ..., s+1-th, s-th] digits of [num_l, nums_(l+1), ..., nums_e]
Example: Consider N = 5, Q =1, A = [1,2,3,4,5], k=2, Queries = [[2.0,2,0,1]], we get the sum of digit of positions 0 an d1 for the first three elements, which is 6, so the answer would be 6
Complete the solve function provided in the editor. This function takes the following 4 parameters and returns array of integers representing the answer of the queries.
N: represents the size of given array
Q: represents the number of queries
nums: represents the given array
Brute force solution was not passing. Can anyone provide an optimized solution?