# Find the Duplicates — coding interview question

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/3056/find-the-duplicates
Source observed: 2026-11-04T22:21:37.204Z
Last checked: 2026-11-04T22:21:37.204+00:00
Indexed: 2026-11-05T19:44:14.31+00:00

---

# Find the Duplicates

**Difficulty:** Easy  
**Category:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms)  
**Also classified as:** [Coding](https://www.aced.io/questions?type=coding)  
**Roles:** [Software Engineer](https://www.aced.io/questions?role=swe), [Data Engineer](https://www.aced.io/questions?role=data-engineer), [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer)  
**Associated companies:** [Apple](https://www.aced.io/questions?company=apple), [Google](https://www.aced.io/questions?company=google), [Amazon](https://www.aced.io/questions?company=amazon), [Adobe](https://www.aced.io/questions?company=adobe)  
**Reported last asked:** 3 months ago  
**Interview reports shown:** 6  
**Saved by:** 77 users

We provide this question through Aced, formerly Exponent, as an interactive coding-practice exercise. The page includes Question, Solution, and Community tabs; the Solution area is locked, and the community area shows 62. The editor is set to Python and includes Output, Test Results, and Console panels. Sign up is required to run code: [Sign up to run code](https://www.aced.io/signup?src=lesson).

## Problem

Given two sorted arrays `arr1` and `arr2` of passport numbers, implement a function `findDuplicates` that returns an array containing every passport number present in both arrays. The output must be sorted in ascending order.

Let `N` and `M` be the lengths of `arr1` and `arr2`, respectively. Solve and analyze both cases:

- `M ≈ N`: the array lengths are approximately the same.
- `M ≫ N`: `arr2` is much bigger than `arr1`.

Analyze the time and space complexity of your solutions.

### Example

```text
input:  arr1 = [1, 2, 3, 5, 6, 7], arr2 = [3, 6, 7, 8, 20]
output: [3, 6, 7] # since only these three values are both in arr1 and arr2
```

## Available practice controls

The page provides expandable **Hint 1**, **Hint 2**, **Hint 3**, and **Challenge 1** sections. No answer has been contributed by the community yet. The code workspace offers a Python selector, Editor and Share modes, plus Output, Test Results, and Console views.

## Interview experiences

We show three linked interview experiences connected with this question:

- [Apple · 3 months ago](https://www.aced.io/experiences/apple-software-engineer-interview-404b0f) — **Software Engineer**. “It was a smooth interview process, they value a lot on their principles. You need to talk through your solution and explain time and space complexity.”
- [Google · 8 months ago](https://www.aced.io/experiences/google-software-engineer-interview-d87459) — **Software Engineer · Entry Level / L3**. “overall smooth. Learned that they really care about full line by line understanding not just throwing things at the wall and what sticks.”
- [Amazon · a year ago](https://www.aced.io/experiences/amazon-software-engineer-interview-1b744e) — **Software Engineer · Entry Level / L3**. “The process was straightforward and detailed. All communications were done promptly and I was notified of every stage.”

## Related questions

- [Find duplicate files in a file system.](https://www.aced.io/questions/2115/find-duplicate-files-file-system)
- [Find and fix the defect causing duplicate alerts.](https://www.aced.io/questions/7279/fix-duplicate-alerts-defect)
- [Given an array of integers, find the first duplicate.](https://www.aced.io/questions/7443/find-first-duplicate-array-integers)

## Related courses

### [Machine Learning Engineer Interview Prep](https://www.aced.io/courses/ml-engineer)

![Machine Learning Engineer Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/6UfkHxUyLQVfDHSfLNQtWa/1be1539a65b4f6f15201f5b573c0a578/ML_Engineer_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for machine-learning roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other companies through mock interviews, frameworks, and advice from senior candidates. The course covers ML system design, core concepts, coding, behavioral interviews, and more.

### [Data Engineering Interview Prep](https://www.aced.io/courses/data-engineering)

![Data Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/5XoOCgXlGqN2fa1zaroNWd/9a2e23df48a212bc00d352873feb2d6a/Data_Engineer_Interview_Prep_Hero_Image.jpg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for data-engineering roles at Meta, Google, Amazon, Microsoft, Walmart, DoorDash, and other companies through mock interviews, frameworks, and advice from senior candidates. The course covers data modeling, pipeline design, SQL, coding, behavioral interviews, and more.

## Aced interview-preparation resources

We provide question practice, courses, interview experiences, coaching, resume review, salary negotiation, job referrals, and resources for technology interviews. Relevant destinations include [all questions](https://www.aced.io/questions), [practice](https://www.aced.io/practice?src=nav), [courses](https://www.aced.io/courses?src=nav), [interview experiences](https://www.aced.io/experiences?src=nav), [coaching](https://www.aced.io/coaching?src=nav), [pricing](https://www.aced.io/upgrade?src=nav), [resume review](https://www.aced.io/resume?src=nav), and [sign up](https://www.aced.io/signup?src=nav).

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3056%2Ffind-the-duplicates&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3056%2Ffind-the-duplicates). Opening a form does not execute a tool.