← Google questions

Find common elements between two arrays

Filed under Google · Also reported at Cognizant

Given two arrays, find all distinct common elements. Provide a solution using a hash map for O(n) time complexity, and a two-pointer approach for sorted arrays to achieve O(n) time and O(1) space.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Google questions

Collected from public candidate posts and coding forums. Updated Nov 2026.