There are three ways, naive approach has n2 complexity, sorting n then doing binary search will take nLog n, hashing by creating Freq map takes n.
https://www.google.com/amp/s/www.geeksforgeeks.org/count-pairs-with-given-sum/amp/
There are three ways, naive approach has n2 complexity, sorting n then doing binary search will take nLog n, hashing by creating Freq map takes n.
https://www.google.com/amp/s/www.geeksforgeeks.org/count-pairs-with-given-sum/amp/