(int[] arr, int n, int k)
| 1 | class Solution |
| 2 | { |
| 3 | int getPairsCount(int[] arr, int n, int k) |
| 4 | { |
| 5 | int counter=0; |
| 6 | HashMap<Integer,Integer> map = new HashMap<>(); |
| 7 | for(int i=0;i<n;i++) |
| 8 | { |
| 9 | int x=k-arr[i]; |
| 10 | if(map.containsKey(x)) |
| 11 | { |
| 12 | counter=counter+map.get(x); |
| 13 | } |
| 14 | if(arr[i]<k) |
| 15 | { |
| 16 | if(map.get(arr[i])==null) |
| 17 | { |
| 18 | map.put(arr[i],0); |
| 19 | } |
| 20 | map.put(arr[i],map.get(arr[i])+1); |
| 21 | } |
| 22 | } |
| 23 | return counter; |
| 24 | } |
| 25 | } |
nothing calls this directly
no outgoing calls
no test coverage detected