Answers for "intersection of 3 array in O(n) python"

0

intersection of 3 array in O(n) python

def intersection(A, B, C):
    '''
    Intersection of 3 array in O(n).
    '''
    i = j = k = 0
    len1 = len(A)
    len2 = len(B)
    len3 = len(C)
	
    while (i < len1 and j < len2 and k< len3):
        
        if (A[i] == B[j] and B[j] == C[k]):
            print(A[i])
            i += 1
            j += 1
            k += 1
        elif A[i] < B[j]:
            i += 1
        elif B[j] < C[k]:
            j += 1
        else:
            k += 1
Posted by: Guest on September-08-2021

Code answers related to "intersection of 3 array in O(n) python"

Python Answers by Framework

Browse Popular Code Answers by Language