# Difference of Arrays

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/3624/difference-of-arrays
Source observed: 2026-11-04T22:21:39.674Z
Last checked: 2026-11-04T22:21:39.674+00:00
Indexed: 2026-11-05T03:43:46.391+00:00

---

# Difference of Arrays

**Difficulty:** Easy  
**Category:** Data Structures & Algorithms; Coding

## Problem

Write a function `diff(arrA, arrB)` that accepts two arrays and returns a new array containing all values that are **not** contained in both input arrays. The order of values in the result does not matter.

## Examples

```python
a = [1, 2, 3, 4]
b = [3, 4, 5, 6]
diff(a, b)  # => [1, 2, 5, 6]
```

The arrays may contain values in different orders or repeated values. Repeated values do not change equivalence; for example, these arrays contain the same values:

```python
a = [1, 2, 1]
b = [2, 1, 2]
diff(a, b)  # => []
```

No community answers have been contributed. The page provides locked Solution access, community discussion, hints, a challenge, an editor, output and test-results panels, and [sign-up to run code](https://www.aced.io/signup?src=lesson).

## Interview metadata

The question is associated with 1 interview and was last reported asked 3 years ago.

## Related question

- [Minimum Absolute Difference](https://www.aced.io/questions/4678/minimum-absolute-difference)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3624%2Fdifference-of-arrays&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%2F3624%2Fdifference-of-arrays). Opening a form does not execute a tool.