Given two arrays of integers where maximum size of first array is big and that of second array is small. Your task is to find if there is a pair in the first array whose sum is present in the second array.
Input: 4 1 5 10 8 3 2 20 13 Output: 1
Approach : We have x + y = z. This can be rewritten as x = z – y. This means, we need to find an element x in array 1 such that it is the result of z(second array) – y(first array). For this, use hashing to keep track of such element x.
- Sudo Placement | Placement Tour
- Check if the array is beautiful
- Sudo Placement[1.4] | K Sum
- Sudo Placement[1.4] | BST Traversal
- Sudo Placement[1.5] | Wolfish
- Sudo Placement[1.5] | Partition
- Sudo Placement 2 | Matrix Series
- Sudo Placement[1.5] | Second Smallest in Range
- Sudo Placement[1.3] | Stack Design
- Sudo Placement[1.4] | Jumping the Subtree
- Sudo Placement[1.3] | Final Destination
- Sudo Placement[1.3] | Playing with Stacks
- Sudo Placement | Special Subsequences
- Sudo Placement | Range Queries
- Sudo Placement | Palindrome Family
This article is contributed by Team GeeksforGeeks. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.