I had 2 integer arrays, one original and one modified w.r.t the original array. Elements can be added or removed from the original to convert it to the modified. My problem is, in the modified, I need to find out which elements are new, which elements are same, and which elements are not there w.r.t to the original array.
Given data:
arr1 = 3,2,1 //Original array
arr2 = 1,4,5 //Modified array by adding and/or removing elements
I need something like:
same = 1
removed = 2,3
added = 4,5
Obviously, I can write several nested for loops and find it out, but this would be too inefficient. I was wondering if there was be a better or efficient way to do it.. I am using Java. This page kind of address a similar problem, but not sure if I can use it to solve my problem.
Any help would be appreciated.