diff --git a/7 January Pair with given sum in a sorted array b/7 January Pair with given sum in a sorted array new file mode 100644 index 0000000..9c4815d --- /dev/null +++ b/7 January Pair with given sum in a sorted array @@ -0,0 +1,16 @@ +class Solution { + public: + int countPairs(vector &arr, int target) { + // Complete the function + int count=0; + unordered_mapmp; + for(int i:arr){ + if(mp.find(target-i)!=mp.end()){ + count+=mp[target-i]; + } + mp[i]++; + } + + return count; + } +};