I did not understand, how brute force approach time complexity is O(n^3)
Check Subarray With Sum Zero
to generate subarrays you have to use 2 loops
so time complexity for just creating subarray is O(N^2)
and for each subarray you have to find the sum
and then check sum is zero or not
hence total time complexity is O(N^3)
okay, got it. thanks.
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.