Which approach to use to solve this question

Should i use the O(n^6) apprach to generate all the sum arrays or us there some other efficient approach to solve this problem

Hello @ this brute force approach is very bad.
You should think of some optimized approach.

Can you suggest which approach should i use, because for generating all subarrays it is taking O(n^6)

Hey @kartiksaxena2000 you have to think of any approach:
like you can do the question in this way:
https://ide.codingblocks.com/s/387431(code).
dry run of the code:
https://ide.codingblocks.com/s/387432
if you have any doubt you can ask here:
Happy Learning!!

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.