# Longest substring without repeating characters — 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/3260/longest-substring-without-repeat
Source observed: 2026-11-04T22:21:37.667Z
Last checked: 2026-11-04T22:21:37.667+00:00
Indexed: 2026-11-05T19:26:03.112+00:00

---

# Find the longest substring without repeating characters

**Difficulty:** Medium  
**Category:** Data Structures & Algorithms  
**Reported last asked:** 2 months ago  
**Interview coverage:** 14 interviews  
**Community:** 72  
**Saved by:** 121 users

We provide this coding interview practice question in our Aced interview-preparation platform, formerly Exponent. The locked **Solution** tab, **Community** tab, Python editor, output panel, test-results panel, and console support interactive practice; [sign up to run code](https://www.aced.io/signup?src=lesson).

## Problem

Given a string `s`, write a function `longestSubstringWithoutRepeat` that returns the length of the longest substring without repeating characters. You may assume that the input string contains only ASCII characters. If the string is empty, return `0`. The substring must consist of contiguous characters, and it cannot include any duplicate characters.

## Examples

```text
Input: s = "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.

Input: s = "bbbbb"
Output: 1
Explanation: The answer is "b", with the length of 1.

Input: s = ""
Output: 0
Explanation: The string is empty, so the answer is 0.
```

The page includes a collapsible **Challenge 1** section. No community answers have been contributed yet.

## Interview details and filters

The question is associated with these roles:

- [Software Engineer — 8](https://www.aced.io/questions?role=swe)
- [Machine Learning Engineer — 2](https://www.aced.io/questions?role=ml-engineer)
- [Data Engineer — 2](https://www.aced.io/questions?role=data-engineer)
- [Forward Deployed Engineer](https://www.aced.io/questions?role=forward-deployed-engineer)
- [Data Scientist](https://www.aced.io/questions?role=data-science)

It is associated with these companies and counts where supplied:

- [Apple — 2](https://www.aced.io/questions?company=apple)
- [Amazon](https://www.aced.io/questions?company=amazon)
- [ElevenLabs](https://www.aced.io/questions?company=eleven-labs)
- [GitHub](https://www.aced.io/questions?company=github)
- [Walmart Labs](https://www.aced.io/questions?company=walmart-labs)
- Spotify
- PayPal
- Salesforce
- Samsung
- JP Morgan Chase
- Intuit
- ANZ
- Microsoft

The question is categorized under [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms&filterBy=codeEditor&src=nav) and [Coding Questions](https://www.aced.io/questions?type=algorithms&filterBy=codeEditor&src=nav).

## Interview experiences

Three shared experiences are associated with this question:

1. [Amazon — Software Engineer · Intern](https://www.aced.io/experiences/amazon-software-engineer-intern-interview-d74e7f), shared 2 months ago:

   > “It was well, interviewer was helpful and was asking mostly standard questions from leetcode. I prepared from Strivers A2Z sheet so it was enough. I could have explained my thinking better”

2. [GitHub — Software Engineer · Intern](https://www.aced.io/experiences/github-software-engineer-intern-interview-1e2a47), shared 7 months ago:

   > “It was a pretty easy process. Everything went pretty well. Interviewers were friendly. The process was very long and drawn out though, four months end to end is a long time.”

3. [ANZ — Software Engineer · Entry Level / L3](https://www.aced.io/experiences/anz-software-engineer-interview-9dd746), shared 2 years ago:

   > “The interview process was straightforward and fairly easy. The questions were reasonable for an entry-level software engineering role, covering basic technical concepts, coding, and discussion of previous projects. Overall, I had a positive experience and didn’t encounter any major issues.”

## Related questions

- [Find the longest repeating substring.](https://www.aced.io/questions/1170/longest-repeating-substring)
- [Find the first repeated character in a given string.](https://www.aced.io/questions/4055/find-first-repeated-character-string)
- [Write a program to find non-repeating characters in a string.](https://www.aced.io/questions/632/find-non-repeating-characters-string)

## 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 offer preparation for machine learning roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies. The course covers mock interviews, frameworks, advice from senior candidates, ML system design, core concepts, coding, and behavioral interviews.

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

![Data Science Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/3U4C5C0OkDR0UeGch4AmlE/7ad489430b676a088cb973307fe77884/Data_Science_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We offer preparation for data science roles at Google, Amazon, Microsoft, Meta, Apple, and other top companies. The course covers statistics, experimentation, coding, SQL, machine learning, behavioral interviews, mock interviews, frameworks, and advice from senior candidates.

## More Aced resources

- [All questions](https://www.aced.io/questions)
- [Courses](https://www.aced.io/courses?src=nav)
- [Practice](https://www.aced.io/practice?src=nav)
- [Mock interviews and coaching](https://www.aced.io/coaching?category=mock_interviews&src=nav)
- [Resume review](https://www.aced.io/resume?src=nav)
- [Pricing and upgrade](https://www.aced.io/upgrade?src=nav)
- [Experiences](https://www.aced.io/experiences?src=nav)
- [Guides](https://www.aced.io/guides?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%2F3260%2Flongest-substring-without-repeat&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%2F3260%2Flongest-substring-without-repeat). Opening a form does not execute a tool.