Longest Unique Substring
Given a string input of length n, find the length of the longest substring without repeating characters i.e return a substring that does not have any repeating characters.
Substring is the continuous sub-part of the string formed by removing zero or more characters from both ends.
Input format:
The first and the only line consists of a string of length n containing lowercase alphabets.
Output format:
You need to print the length of the longest unique characters substring.
Constraints:
1<= n <=10^5
Time Limit: 1 sec
CodingNinjas
author
2y
All Substring Approach
- Create all the substrings of the string.
- For every substring, check if it consists of unique characters.
- To check if the substring has duplicate characters, we will use a HashSet. ...read more
CodingNinjas
author
2y
Sliding Window Approach
- Take two pointers (start and end) initially both at 0th index and a set which will be storing the characters between start and end index.
- While both pointers are less than the le...read more
Help your peers!
Add answer anonymously...
Top Freshworks Lead Software Engineer interview questions & answers
Popular interview questions of Lead Software Engineer
Top HR questions asked in Freshworks Lead Software Engineer
>
Freshworks Lead Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
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