Sub array with sum zero

it his problem if we know that in prefix sum array of the given array at any two indices if there is same value of prefix array
then we have a with sum equal to zero…
for example - 6 5 7 8 7
so why we cannot do like this is just iterate the whole prefix array if there is any element whose count is greater than 2 then we simply return that we have a sub array with a sum equal to zero…why do we even need to use hashmap?..
and iterating the prefix array will take O(n) time…am i right?

@archa_1712 hey ,yes you can use array also but map is more easy to use as it contains various functions which make work easier ,also you can use array but it will be difficult to store indexes in array.

okay!..

what is a differnce between an unordered set and an unordered map?

@archa_1712
Unordered_set properties:
(i) Elements can be stored in any order. ( no sorted order )
(ii) Stores only unique values.
(iii) Hash-table used to store elements.
(iv) We can erase only the element for which iterator position is given.

unordered_map properties:
It is an associated container that stores elements formed by combination of key value and a mapped value. The key value is used to uniquely identify the element and mapped value is the content associated with the key. Both key and value can be of any type predefined or user-defined.

set store unique elements but ,map store all elements.


map stores unique elements i think

@archa_1712 yes you are right but ap unordered ki bat krrhe ho na

haa unordered …unordered unique nia store krata?

@archa_1712 hey ,difference sirf itna hai , unordered_map vs unordered_set :
In unordered_set, we have only key, no value, these are mainly used to see presence/absence in a set. For example, consider the problem of counting frequencies of individual words. We can’t use unordered_set (or set) as we can’t store counts.

Okay…i got it!..

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.