{"id":"8a0e0658-e415-40e3-a88b-1d0ab0eeaf9f","name":"Target Sum Pair 1","description":"<p>1. You are given an array(arr) of distinct integers and a target. 2. You have to print all the pairs having their sum equal to the target.</p>","inputFormat":"<p>An Integer N arr1 arr2.. n integers An integer target</p>","outputFormat":"<p>Check the sample output and question video.</p>","constraints":"<p>1 &lt;= N &lt;= 10000 -10^9&lt;= arr[i] &lt;= 10^9</p>","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\nvoid input(vector<int> &arr)\n{\n for (int i = 0; i < arr.size(); i++)\n {\n cin >> arr[i];\n }\n}\nvoid targetSumPair(vector<int> &arr, int target)\n{\n //write your code here\n}\nint main()\n{\n int n, target;\n cin >> n;\n vector<int> vec(n, 0);\n input(vec);\n cin >> target;\n targetSumPair(vec, target);\n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void targetSumPair(int[] arr, int target){\r\n //write your code here\r\n\r\n }\r\n public static void main(String[] args) throws Exception {\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 int target = scn.nextInt();\r\n targetSumPair(arr,target);\r\n }\r\n\r\n}"},"python":{"code":"def targetSumPair(arr,target):\n #write your code here\n\n\nn=int(input());\narr=[];\nfor i in range(0,n):\n val=int(input());\n arr.append(val);\ntarget=int(input());\ntargetSumPair(arr,target);"}},"points":10,"difficulty":"easy","sampleInput":"12\r\n9 \r\n-48 \r\n100 \r\n43 \r\n84 \r\n74 \r\n86 \r\n34 \r\n-37 \r\n60 \r\n-29 \r\n44\r\n160","sampleOutput":"60, 100\r\n74, 86","questionVideo":"https://www.youtube.com/embed/4t9jv9AkVdE?end=151","hints":[],"associated":[{"id":"5d4f90dd-44cb-4ec5-af76-056e9fc0b4c4","name":"What will be the overall Time Complexity of Target Sum Pair?","slug":"what-will-be-the-overall-time-complexity-of-target-sum-pair","type":4},{"id":"76cae033-74ac-445d-8f41-92158054f69b","name":"What is the Time Complexity of in-built function","slug":"what-is-the-time-complexity-of-in-built-function","type":4},{"id":"8a4a2cba-3412-483f-91c8-e94c9c7c0f03","name":"Where do we put the two pointers initially?","slug":"where-do-we-put-the-two-pointers-initially","type":4},{"id":"e65a054d-6a1d-4cf4-8a86-a49a21047f39","name":"How do we declare In-Built sorting function ?","slug":"how-do-we-declare-in-built-sorting-function","type":4}],"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":"8e3abac7-a5ab-4090-abd1-b26ef8b53d70","name":"Time and Space Complexity","slug":"time-and-space-complexity","type":0},{"id":"0dccab5c-929a-48ad-baa8-6df06478b0b3","name":"Target Sum Pair 1","slug":"target-sum-pair-1","type":1}],"next":{"id":"8dfb6ac8-d52c-426e-b995-d9a1022d22d6","name":"Target Sum Pair-1","type":3,"slug":"target-sum-pair-1"},"prev":{"id":"9807148e-86a0-4153-bbcd-a17622bff866","name":"Sort 012","type":3,"slug":"sort-012"}}}

Target Sum Pair 1

<p>1. You are given an array(arr) of distinct integers and a target. 2. You have to print all the pairs having their sum equal to the target.</p>

{"id":"8a0e0658-e415-40e3-a88b-1d0ab0eeaf9f","name":"Target Sum Pair 1","description":"<p>1. You are given an array(arr) of distinct integers and a target. 2. You have to print all the pairs having their sum equal to the target.</p>","inputFormat":"<p>An Integer N arr1 arr2.. n integers An integer target</p>","outputFormat":"<p>Check the sample output and question video.</p>","constraints":"<p>1 &lt;= N &lt;= 10000 -10^9&lt;= arr[i] &lt;= 10^9</p>","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\nvoid input(vector<int> &arr)\n{\n for (int i = 0; i < arr.size(); i++)\n {\n cin >> arr[i];\n }\n}\nvoid targetSumPair(vector<int> &arr, int target)\n{\n //write your code here\n}\nint main()\n{\n int n, target;\n cin >> n;\n vector<int> vec(n, 0);\n input(vec);\n cin >> target;\n targetSumPair(vec, target);\n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void targetSumPair(int[] arr, int target){\r\n //write your code here\r\n\r\n }\r\n public static void main(String[] args) throws Exception {\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 int target = scn.nextInt();\r\n targetSumPair(arr,target);\r\n }\r\n\r\n}"},"python":{"code":"def targetSumPair(arr,target):\n #write your code here\n\n\nn=int(input());\narr=[];\nfor i in range(0,n):\n val=int(input());\n arr.append(val);\ntarget=int(input());\ntargetSumPair(arr,target);"}},"points":10,"difficulty":"easy","sampleInput":"12\r\n9 \r\n-48 \r\n100 \r\n43 \r\n84 \r\n74 \r\n86 \r\n34 \r\n-37 \r\n60 \r\n-29 \r\n44\r\n160","sampleOutput":"60, 100\r\n74, 86","questionVideo":"https://www.youtube.com/embed/4t9jv9AkVdE?end=151","hints":[],"associated":[{"id":"5d4f90dd-44cb-4ec5-af76-056e9fc0b4c4","name":"What will be the overall Time Complexity of Target Sum Pair?","slug":"what-will-be-the-overall-time-complexity-of-target-sum-pair","type":4},{"id":"76cae033-74ac-445d-8f41-92158054f69b","name":"What is the Time Complexity of in-built function","slug":"what-is-the-time-complexity-of-in-built-function","type":4},{"id":"8a4a2cba-3412-483f-91c8-e94c9c7c0f03","name":"Where do we put the two pointers initially?","slug":"where-do-we-put-the-two-pointers-initially","type":4},{"id":"e65a054d-6a1d-4cf4-8a86-a49a21047f39","name":"How do we declare In-Built sorting function ?","slug":"how-do-we-declare-in-built-sorting-function","type":4}],"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":"8e3abac7-a5ab-4090-abd1-b26ef8b53d70","name":"Time and Space Complexity","slug":"time-and-space-complexity","type":0},{"id":"0dccab5c-929a-48ad-baa8-6df06478b0b3","name":"Target Sum Pair 1","slug":"target-sum-pair-1","type":1}],"next":{"id":"8dfb6ac8-d52c-426e-b995-d9a1022d22d6","name":"Target Sum Pair-1","type":3,"slug":"target-sum-pair-1"},"prev":{"id":"9807148e-86a0-4153-bbcd-a17622bff866","name":"Sort 012","type":3,"slug":"sort-012"}}}
plane

Editor


Loading...

Target Sum Pair 1

easy

1. You are given an array(arr) of distinct integers and a target. 2. You have to print all the pairs having their sum equal to the target.

Constraints

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

Format

Input

An Integer N arr1 arr2.. n integers An integer target

Output

Check the sample output and question video.

Example

Sample Input

12 9 -48 100 43 84 74 86 34 -37 60 -29 44 160

Sample Output

60, 100 74, 86

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode