bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1213. Intersection of Three Sorted Arrays

1213. Intersection of Three Sorted Arrays

Leetcode Solutions

Approach: Three Pointers

  1. Initialize three pointers p1, p2, and p3 to 0 to point to the start of arr1, arr2, and arr3 respectively.
  2. While 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].
  3. Return the result list containing the common elements.
UML Thumbnail

Approach: Brute Force with Hashmap

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...