`{"id":"9a71a3f6-b5b1-41bc-85df-a3dc8b34a58a","name":"Pairs With Equal Sum","description":"1. You are given an array(arr) of distinct integers.\r\n2. You have to find if there are two pairs(A, B) and (C, D) present in the given array which satisfies the condition A+B = C+D.","inputFormat":"A number N\r\narr1\r\narr2.. N numbers","outputFormat":"true/false","constraints":"1 &lt;= N &lt;= 10^3\r\n-10^9 &lt;= arr[i] &lt;= 10^9 ","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\n\nusing namespace std;\n\nbool solution(vector<int>& arr, int n) {\n // write your code here\n}\n\nint main() {\n int n;\n cin >> n;\n vector<int> arr(n);\n for (int i = 0; i < n; i++) {\n cin >> arr[i];\n }\n bool ans = solution(arr, n);\n if (ans == 0) {\n cout << \"false\";\n } else {\n cout << \"true\";\n }\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static boolean solution(int[] arr) {\r\n // write your code here\r\n\r\n return false;\r\n }\r\n \r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[] arr = new int[n];\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n System.out.println(solution(arr));\r\n }\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"8\r\n1 2 998 72 87576 21 45 -1","sampleOutput":"false\r\n","questionVideo":"https://www.youtube.com/embed/11U8TjquNjY?end=12","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"ad39d8c9-a845-43a0-9972-b13930781402","name":"Pairs With Equal Sum","slug":"pairs-with-equal-sum","type":1}],"next":{"id":"b049f283-d71b-458f-a367-fe51ec3b2297","name":"Pairs With Equal Sum MCQ","type":0,"slug":"pairs-with-equal-sum-mcq"},"prev":{"id":"7463629f-2103-47a9-89a1-35482b095538","name":"Count of Subarrays with Equal Number of 0s 1s and 2s","type":3,"slug":"count-of-subarrays-with-equal-number-of-0s-1s-and-2s"}}}`

# Pairs With Equal Sum

1. You are given an array(arr) of distinct integers. 2. You have to find if there are two pairs(A, B) and (C, D) present in the given array which satisfies the condition A+B = C+D.

`{"id":"9a71a3f6-b5b1-41bc-85df-a3dc8b34a58a","name":"Pairs With Equal Sum","description":"1. You are given an array(arr) of distinct integers.\r\n2. You have to find if there are two pairs(A, B) and (C, D) present in the given array which satisfies the condition A+B = C+D.","inputFormat":"A number N\r\narr1\r\narr2.. N numbers","outputFormat":"true/false","constraints":"1 &lt;= N &lt;= 10^3\r\n-10^9 &lt;= arr[i] &lt;= 10^9 ","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\n\nusing namespace std;\n\nbool solution(vector<int>& arr, int n) {\n // write your code here\n}\n\nint main() {\n int n;\n cin >> n;\n vector<int> arr(n);\n for (int i = 0; i < n; i++) {\n cin >> arr[i];\n }\n bool ans = solution(arr, n);\n if (ans == 0) {\n cout << \"false\";\n } else {\n cout << \"true\";\n }\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static boolean solution(int[] arr) {\r\n // write your code here\r\n\r\n return false;\r\n }\r\n \r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[] arr = new int[n];\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n System.out.println(solution(arr));\r\n }\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"8\r\n1 2 998 72 87576 21 45 -1","sampleOutput":"false\r\n","questionVideo":"https://www.youtube.com/embed/11U8TjquNjY?end=12","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"ad39d8c9-a845-43a0-9972-b13930781402","name":"Pairs With Equal Sum","slug":"pairs-with-equal-sum","type":1}],"next":{"id":"b049f283-d71b-458f-a367-fe51ec3b2297","name":"Pairs With Equal Sum MCQ","type":0,"slug":"pairs-with-equal-sum-mcq"},"prev":{"id":"7463629f-2103-47a9-89a1-35482b095538","name":"Count of Subarrays with Equal Number of 0s 1s and 2s","type":3,"slug":"count-of-subarrays-with-equal-number-of-0s-1s-and-2s"}}}` Editor

# Pairs With Equal Sum

easy

1. You are given an array(arr) of distinct integers. 2. You have to find if there are two pairs(A, B) and (C, D) present in the given array which satisfies the condition A+B = C+D.

## Constraints

1 <= N <= 10^3 -10^9 <= arr[i] <= 10^9

## Format

### Input

A number N arr1 arr2.. N numbers

true/false

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}8 1 2 998 72 87576 21 45 -1```

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}false ```

Question Video

Discussions

Show Discussion

Related Resources 