467,166 Members | 1,073 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,166 developers. It's quick & easy.

Problem about unique integers given two arrays

Given two arrays (the first array and the second array) of the same size,
each consisting of n positive integers, I want to write a c++ program to determine how many unique integers the second array have. Here a unique integer means that it shows only once in the second array but does not show in the first array. For example, if the first array is [1, 5, 3, 6, 8] and the second array is [2, 4, 2, 5, 9] (with n=5), the second array
has two unique integers (4 and 9)
Nov 26 '20 #1
  • viewed: 3592
Share:
2 Replies
Expert 256MB
Given two arrays (the first array and the second array) of the same size,
each consisting of n positive integers, I want to write a c++ program to determine how many unique integers the second array have. Here a unique integer means that it shows only once in the second array but does not show in the first array. For example, if the first array is [1, 5, 3, 6, 8] and the second array is [2, 4, 2, 5, 9] (with n=5), the second array
has two unique integers (4 and 9)
Select an element from the second. Compare it with every element in the first. If there's no match, check for the repetition.
Nov 26 '20 #2
64KB
Hello,

For this you have to find unique element in second array. for finding unique element refer following site:

https://www.geeksforgeeks.org/print-...integer-array/

For finding unique element in second array which are not present in first array refer following site:

https://www.geeksforgeeks.org/find-e...ay-not-second/

Thank you
Dec 2 '20 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

12 posts views Thread by Kelly Goode | last post: by
4 posts views Thread by andreas.fabri@geometryfactory.com | last post: by
36 posts views Thread by Robert Baer | last post: by
16 posts views Thread by Mark S. | last post: by
3 posts views Thread by sberry | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.