Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7646481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:13:10+00:00 2026-05-31T10:13:10+00:00

Given a string S of length N find longest substring without repeating characters. Example:

  • 0

Given a string S of length N find longest substring without repeating characters.

Example:

Input: “stackoverflow”

Output: “stackoverfl”

If there are two such candidates, return first from left. I need linear time and constant space algorithm.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:13:12+00:00Added an answer on May 31, 2026 at 10:13 am
    1. You are going to need a start and an end locator(/pointer) for the
      string and an array where you store information for each character:
      did it occour at least once?

    2. Start at the beginning of the string, both locators point to the
      start of the string.

    3. Move the end locator to the right till you find
      a repetition (or reach the end of the string). For each processed character, store it in the array.
      When stopped store the position if this is the largest substring. Also remember the repeated character.

    4. Now do the same thing with the start locator, when processing
      each character, remove its flags from the array. Move the locator till
      you find the earlier occurrence of the repeated character.

    5. Go back to step 3 if you haven’t reached the end of string.

    Overall: O(N)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find the shortest and longest word in a given string.
Given a string of length N containing characters [A-Z], how do I determine the
Is there a way to determine the display length of a given string (in
I'd like to find the longest repeating string within a string, implemented in JavaScript
I'm running this query, I need to find out the longest string in a
Problem: Given a list of strings, find the substring which, if subtracted from the
Given a list L of n character strings, and an input character string S,
Given a string as a form of input (parsed from an input file) which
I want to find a nonempty, contiguous subarray for a given input array of
I'm writing a C program to find the longest line in the user's input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.