LC: 1213. Intersection of Three Sorted Arrays - spiralgo/algorithms GitHub Wiki

1213. Intersection of Three Sorted Arrays:

The Essence:

  • All arrays have solely consist of integer elements.
  • All arrays are sorted in strictly increasing order as is emphasized.
  • Strictly increasing order implies that all elements are unique.

Therefore, we can assume these arrays are just altered versions of the same array (or subsets of the same integer set.).

The arrays are altered by removing some elements from each. The question asks which elements were not removed and still exist in all of the arrays.

Details:

As we know arrays are sorted in strictly increasing order, we can traverse all of them at the same time, using a pointer for each. If we come across the same value for all pointers, it means we found one intersection. Otherwise, we should move the pointers by value comparison.