# 01 Matrix — 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/4683/01-matrix
Source observed: 2026-11-05T00:44:47.291Z
Last checked: 2026-11-05T00:44:47.291+00:00
Indexed: 2026-11-06T16:19:59.342+00:00

---

# 01 Matrix

We provide this coding interview question for practicing data structures and algorithms.

## Problem

Given an **M × N binary matrix**, calculate the distance from each cell to the nearest `0`. Return a new matrix in which every cell contains that distance.

## Interview details

- **Interview count:** 2
- **Category:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms)
- **Additional category:** [Coding](https://www.aced.io/questions?type=coding)
- **Roles:** [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer), [Software Engineer](https://www.aced.io/questions?role=swe)
- **Companies:** [Adobe](https://www.aced.io/questions?company=adobe), [Oracle](https://www.aced.io/questions?company=oracle)
- **Reported last asked:** 2 years ago

## Access and answers

Detailed company statistics are available through [Upgrade](https://www.aced.io/upgrade?src=questions). No community answers have been contributed yet. To submit an answer, log in or sign up; submitting marks the question complete.

## Related questions

- [Set Matrix Zeroes](https://www.aced.io/questions/4016/set-matrix-zeroes)
- [Rotate a 2D matrix.](https://www.aced.io/questions/7183/rotate-2d-matrix)

## 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 top companies through mock interviews, frameworks, and advice from senior candidates. The course covers ML system design, core concepts, coding, behavioral interviews, and more.

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

![Software Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/4VkuYewBHUFIVUS5oJDW5h/02e833439b1289f25f38f13f81cbdca3/adobe_stock_optimized.jpeg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for software engineering roles at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Practice data structures, algorithms, system design, people management, behavioral interviews, and more through mock interviews, frameworks, and advice from senior candidates.

## Your answer

Use the answer area after logging in or signing up. Submitting your answer marks this question complete.

---

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