Let’s look at the following case:
In this case the common values are ivr, add and web meanwhile the others were excluded because they were not present in all arrays.
Seen my case, I’m not aware how many element an array can have and also how many arrays can I have. But the once thing that I aware was the possible data within the array.
I fully leaned on this last and only piece of information I had available to avoid too many cycles.
The solution that I used to get this algorithm is:
I have created an array with all possible values (commonChannels).
I started to cycle all arrays then every within item each
Whenever an element was missing it was excluded from the array. To do this I rewrote the base variable (commonChannels)
To exclude the elements I’ve combined of the Filter and IndexOf methods.