what is the key value pair in problem (find the pair of elements which sum to zero) ?
Hashing problems
Hello @rishipandey7,
In this question, you can use map to solve the question.
The key will be the element of the given sequence itself and
the value will be its count in the sequence at any instant of time.
Approach:
- Read characters (say a) one by one and do the following for each:
- if -a(negative of a) is not present in the hash-map:
…increment its count - if -a is present in the hash-map:
… then print the pair(-a,a), map[-a] (i.e. corresponding count) times.
… do not store a in the map.
Hope, this would help.
Give a like if you are satisfied.
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.