• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
April 26, 2022 |11.3K Views
Swapping pairs make sum equal | SDE Sheet | Arrays
  Share  8 Likes
Description
Discussion

In this video we will see when given two arrays of integers, how to find a pair of values (one value from each array) that you can swap to give the two arrays the same sum. Examples: Input: A[] = {4, 1, 2, 1, 1, 2}, B[] = (3, 6, 3, 3) Output: {1, 3} Sum of elements in A[] = 11 Sum of elements in B[] = 15 To get same sum from both arrays, we can swap following values: 1 from A[] and 3 from B[] Check out the video to see how we implement this!! Practice Problem: https://practice.geeksforgeeks.org/problems/swapping-pairs-make-sum-equal4142/1 Article: https://www.geeksforgeeks.org/find-a-pair-swapping-which-makes-sum-of-two-arrays-same/ SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More