Is the array has the subarray has sum of 0

Revision en1, by ucode.vn, 2021-11-23 16:10:38

sum(a[i,j]) = prefix_sum[j] — prefix_sum[i-1] => sum(a[i,j]) = 0 when 1 prefix_sum in the previous prefix_sum or this prefix_sum equal 0

I have a set data structure that stores prefix_sum1 . values and 1 variable prefix_sum Browse each index i from 0 -> n-1 : add prefix_sum a[i] if prefix_sum is in prefix_sum1 then return True If prefix_sum is 0, return True add prefix_sum1 prefix_sum Then all box fields that return True have been processed. And Returns False

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ucode.vn 2021-11-23 16:10:38 522 Initial revision (published)