`{"id":"9b356e97-b42e-4397-9f2f-4b0822277e9a","name":"Quadruplet Sum - 2","description":"1. You are given four arrays(A1,A2,A3,A4) of integers. All arrays are of same length(N).\r\n2. You have to find the count of all unique quadruplets(a,b,c,d) such that - \r\n A1[a] + A2[b] + A3[c] + A4[d] = 0.","inputFormat":"5 lines, where the first line contains a number N,\r\nAnd every next line contains N space-separated integers.","outputFormat":"A number representing the count of all unique quadruplets having sum zero.","constraints":"1 &lt;= N &lt;= 200\r\n-10^3 &lt;= elements of all arrays &lt;= 10^3","sampleCode":{"cpp":{"code":"#include <iostream>\r\n#include <vector>\r\n\r\nusing namespace std;\r\n\r\nvoid input(vector<int> &arr)\r\n{\r\n for (int i = 0; i < arr.size(); i++)\r\n {\r\n cin >> arr[i];\r\n }\r\n}\r\n\r\nint fourSumCount(vector<int> &A, vector<int> &B, vector<int> &C, vector<int> &D)\r\n{\r\n\r\n return 0;\r\n}\r\n\r\nint main()\r\n{\r\n\r\n int n;\r\n cin >> n;\r\n vector<int> arr1(n, 0);\r\n vector<int> arr2(n, 0);\r\n vector<int> arr3(n, 0);\r\n vector<int> arr4(n, 0);\r\n\r\n input(arr1);\r\n input(arr2);\r\n input(arr3);\r\n input(arr4);\r\n cout << fourSumCount(arr1, arr2, arr3, arr4);\r\n return 0;\r\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\t\r\n public static int fourSumCount(int[] A, int[] B, int[] C, int[] D) {\r\n\t\t// write your code here\r\n\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner sc = new Scanner(System.in);\r\n\t\tint n = sc.nextInt();\r\n\t\tint[] arr1 = new int[n];\r\n\t\tint[] arr2 = new int[n];\r\n\t\tint[] arr3 = new int[n];\r\n\t\tint[] arr4 = new int[n];\r\n\t\tfor (int i = 0; i < n; i++) {\r\n\t\t\tarr1[i] = sc.nextInt();\r\n\t\t}\r\n\t\tfor (int i = 0; i < n; i++) {\r\n\t\t\tarr2[i] = sc.nextInt();\r\n\t\t}\r\n\t\tfor (int i = 0; i < n; i++) {\r\n\t\t\tarr3[i] = sc.nextInt();\r\n\t\t}\r\n\t\tfor (int i = 0; i < n; i++) {\r\n\t\t\tarr4[i] = sc.nextInt();\r\n\t\t}\r\n\t\tSystem.out.println(fourSumCount(arr1, arr2, arr3, arr4));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"2\r\n1 2\r\n-2 -1\r\n-1 2\r\n0 2","sampleOutput":"2\r\n","questionVideo":"","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":"3713e986-3e1d-4202-aadd-945abad3d5b0","name":"Quadruplet Sum - 2","slug":"quadruplet-sum-2","type":1}],"next":{"id":"0ecceb9a-63b9-439a-98cd-9559c4b0c70b","name":"Quadruplet Sum - 2 MCQ","type":0,"slug":"quadruplet-sum-2-mcq"},"prev":{"id":"216498b9-ac24-4d06-83b2-6208936f008e","name":"Quadruplet Sum","type":3,"slug":"quadruplet-sum"}}}`

1. You are given four arrays(A1,A2,A3,A4) of integers. All arrays are of same length(N). 2. You have to find the count of all unique quadruplets(a,b,c,d) such that - A1[a] + A2[b] + A3[c] + A4[d] = 0.

`{"id":"9b356e97-b42e-4397-9f2f-4b0822277e9a","name":"Quadruplet Sum - 2","description":"1. You are given four arrays(A1,A2,A3,A4) of integers. All arrays are of same length(N).\r\n2. You have to find the count of all unique quadruplets(a,b,c,d) such that - \r\n A1[a] + A2[b] + A3[c] + A4[d] = 0.","inputFormat":"5 lines, where the first line contains a number N,\r\nAnd every next line contains N space-separated integers.","outputFormat":"A number representing the count of all unique quadruplets having sum zero.","constraints":"1 &lt;= N &lt;= 200\r\n-10^3 &lt;= elements of all arrays &lt;= 10^3","sampleCode":{"cpp":{"code":"#include <iostream>\r\n#include <vector>\r\n\r\nusing namespace std;\r\n\r\nvoid input(vector<int> &arr)\r\n{\r\n for (int i = 0; i < arr.size(); i++)\r\n {\r\n cin >> arr[i];\r\n }\r\n}\r\n\r\nint fourSumCount(vector<int> &A, vector<int> &B, vector<int> &C, vector<int> &D)\r\n{\r\n\r\n return 0;\r\n}\r\n\r\nint main()\r\n{\r\n\r\n int n;\r\n cin >> n;\r\n vector<int> arr1(n, 0);\r\n vector<int> arr2(n, 0);\r\n vector<int> arr3(n, 0);\r\n vector<int> arr4(n, 0);\r\n\r\n input(arr1);\r\n input(arr2);\r\n input(arr3);\r\n input(arr4);\r\n cout << fourSumCount(arr1, arr2, arr3, arr4);\r\n return 0;\r\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\t\r\n public static int fourSumCount(int[] A, int[] B, int[] C, int[] D) {\r\n\t\t// write your code here\r\n\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner sc = new Scanner(System.in);\r\n\t\tint n = sc.nextInt();\r\n\t\tint[] arr1 = new int[n];\r\n\t\tint[] arr2 = new int[n];\r\n\t\tint[] arr3 = new int[n];\r\n\t\tint[] arr4 = new int[n];\r\n\t\tfor (int i = 0; i < n; i++) {\r\n\t\t\tarr1[i] = sc.nextInt();\r\n\t\t}\r\n\t\tfor (int i = 0; i < n; i++) {\r\n\t\t\tarr2[i] = sc.nextInt();\r\n\t\t}\r\n\t\tfor (int i = 0; i < n; i++) {\r\n\t\t\tarr3[i] = sc.nextInt();\r\n\t\t}\r\n\t\tfor (int i = 0; i < n; i++) {\r\n\t\t\tarr4[i] = sc.nextInt();\r\n\t\t}\r\n\t\tSystem.out.println(fourSumCount(arr1, arr2, arr3, arr4));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"2\r\n1 2\r\n-2 -1\r\n-1 2\r\n0 2","sampleOutput":"2\r\n","questionVideo":"","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":"3713e986-3e1d-4202-aadd-945abad3d5b0","name":"Quadruplet Sum - 2","slug":"quadruplet-sum-2","type":1}],"next":{"id":"0ecceb9a-63b9-439a-98cd-9559c4b0c70b","name":"Quadruplet Sum - 2 MCQ","type":0,"slug":"quadruplet-sum-2-mcq"},"prev":{"id":"216498b9-ac24-4d06-83b2-6208936f008e","name":"Quadruplet Sum","type":3,"slug":"quadruplet-sum"}}}` Editor

medium

1. You are given four arrays(A1,A2,A3,A4) of integers. All arrays are of same length(N). 2. You have to find the count of all unique quadruplets(a,b,c,d) such that - A1[a] + A2[b] + A3[c] + A4[d] = 0.

## Constraints

1 <= N <= 200 -10^3 <= elements of all arrays <= 10^3

## Format

### Input

5 lines, where the first line contains a number N, And every next line contains N space-separated integers.

### Output

A number representing the count of all unique quadruplets having sum zero.

## 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;}2 1 2 -2 -1 -1 2 0 2```

### 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;}2 ```

Discussions

Show Discussion

Related Resources 