# Write a Python function to find intersection of two sorted arrays

## Topic: Write a Python function to find intersection of two sorted arrays

Solution

def printIntersection(arr1, arr2, m, n): i, j = 0, 0 while i < m and j < n: if arr1[i] < arr2[j]: i += 1 elif arr2[j] < arr1[i]: j+= 1 else: print(arr2[j]) j += 1 i += 1 arr1 = [1, 2, 4, 5, 6] arr2 = [2, 3, 5, 7] m = len(arr1) n = len(arr2) printIntersection(arr1, arr2, m, n)

List all Python Programs