p1
, p2
, and p3
to 0 to point to the start of arr1
, arr2
, and arr3
respectively.p1
, p2
, and p3
are within the boundaries of their respective arrays:
a. If arr1[p1]
, arr2[p2]
, and arr3[p3]
are all equal, add arr1[p1]
to the result list and increment all three pointers.
b. Else, increment the pointer that points to the smallest element among arr1[p1]
, arr2[p2]
, and arr3[p3]
.