How to find uncommon elements from three arrays?

BlackBoxSql

A,B,C are the arrays :

A = {1,2,3,4}
B = {8,1,2,3}
C = {1,2,9,3}

Result is the uncommon values from three arrays

Result = {4,8,9}

Asking for the logic what I can implement ?

the.salman.a

There might be some other better answers. But here is the most simple one.

  1. On line 4 I took the Intersection of 3 sets
  2. On line 7 I took the Union of three sets
  3. On line 10 the difference or XOR operation, of Union and intersection

I hope it helps:-

>>> a = {1,2,3,4}
>>> b = {8,1,2,3}
>>> c = {1,2,9,3}

>>> d = a & b & c
>>> print(d)
{1, 2, 3}

>>> e = a | b | c
>>> print(e)
{1, 2, 3, 4, 8, 9}

>>> f = d^e
>>> print(f)
{4, 8, 9}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Compare two arrays and find the index of uncommon elements in SWIFT 3

Find uncommon elements using hashing

Get uncommon elements from two list - KOTLIN

Find common element in two from three arrays

How to access uncommon properties from two different object arrays that are combined into one?

How to find the index with the same value in three arrays

Find the same elements of an array from other arrays?

How to sort and find three largest elements in array?

How to find the uncommon words from two files using only terminal commands in OSX?

How to find same elements in different arrays Swift

How to find common elements in two arrays?

MongoDB aggregation: how to find common elements from two arrays of two different collections

How to query mongo to find arrays that contain any of the elements from another array?

How to Merge Three Arrays by grouping Elements under the same Index together

How can I merge the elements of three arrays with same ID's?

How to print Scanner elements from Arrays in java?

How to remove elements from object of arrays

Javascript find objects that contain matching elements from arrays in another object

How to compare two arrays and find the indices where the elements differ?

How to use HashSet to find common elements in two Comparable arrays?

How to find common elements only between 2 arrays in jquery

Find the three largest elements in an array

How to merge three arrays?

How to extract uncommon case insensitive text from two files?

How to get uncommon objects from two list of diferent objects

how to get uncommon value's from table 1 and table 2

How to create JSON or Array of Objects From Three JS Arrays

How to make one array from three arrays having common fields

Given two arrays with same size, find the couple of elements from both arrays that make sum with the smallest absolute value

TOP Ranking

HotTag

Archive