MLE Ocuur in MatrixQuery

CodeLink->https://ide.codingblocks.com/s/258933

@imsaurabh
I just check your code. Your logic is correct but you are wasting lot of memory. I am suggesting few thing to reduce memory

  1. see you’ve define int as long long int. So everywhere in your code you were using long long int. Change it and use long long int wherever needed. like in for loop long long int is not require.
  2. In your multiply() function, you are creating 2d array **c everytime. Make it global or delete it if possible
  3. Similarly in your query function, you are creating array **a everytime which in not required. Make it global.
  4. For every query you are creating **res array which again not required. Either make it global or delete it at the end of each iteration.
  5. Reduce size of your segment tree to 3*n +1. It works fine for this size.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.