Longest Substring Without Repeating Characters

Given a string 'S' of length 'L', return the length of the longest substring without repeating characters.

Example:

Suppose given input is "abacb", then the length of the longest substring without repeating characters will be 3 ("acb").
Input Format:
Each input contains a single line which contains the string 'S', Where 'S' denotes the input string containing english letters ( both UpperCase and LowerCase), digits, symbols, and spaces.
Output Format:
Print a single integer denoting the length of the longest substring without repeating characters.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
0 <= L <= 10^5     

Time limit: 1 sec
Follow Up:
Can you solve this problem in O(L) time and space complexity?
CodingNinjas
author
2y
Brute Force

In the brute force approach, we will use two nested loops. The outer loop is used to select the starting index of the substring and the inner loop is used to fix the ending index of the sub...read more

CodingNinjas
author
2y
Optimized Brute Force

In this approach, we will use two nested loops. The outer loop is used to select the starting index of the substring and the inner loop is used to fix the ending index of the subs...read more

CodingNinjas
author
2y
Binary Search

In this approach, we will use a binary search to select the length of the substring. The smallest value possible will be 1 as all the characters are unique substrings themselves and the m...read more

CodingNinjas
author
2y
Sliding Window Approach

We will keep a window that will keep a range of unique characters where the range is defined by start and end indices. Initially, both ‘start' and ‘end’ equal to zero denoting t...read more

Add answer anonymously...
Avalara Technologies Technical Lead Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter