`{"id":"c6bfa29d-be9b-4ce2-9123-9e34e0feb36e","name":"Longest Substring With Non Repeating Characters","description":"1. You are given a string.\r\n2. You have to find the length of the longest substring of the given string that contains all non-repeating characters.","inputFormat":"A string","outputFormat":"A number representing the length of longest substring with unique characters.","constraints":"1 &lt;= length of string &lt;= 10^5","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\n\nint solution(string str){\n // write your code here\n}\n\nint main(){\n\tstring str;\n\tcin>>str;\n\tcout <<solution(str);\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String str) {\r\n\t\t// write your code here\r\n\t\t\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tSystem.out.println(solution(str));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"aabcbcdbca","sampleOutput":"4\r\n","questionVideo":"https://www.youtube.com/embed/9Kc0eZBGL1U?end=13","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"aa00364a-2a79-46f9-b4d1-fdef27782250","name":"Longest Substring With Non Repeating Characters","slug":"longest-substring-with-non-repeating-characters","type":1}],"next":{"id":"bd3e3857-f817-4870-a336-bd819b1a6c4d","name":"Longest Substring With Non Repeating Characters MCQ","type":0,"slug":"longest-substring-with-non-repeating-characters-mcq"},"prev":{"id":"226e8d15-bc56-4516-ba18-cd01d32f7e40","name":"Smallest Substring Of A String Containing All Unique Characters Of Itself","type":3,"slug":"smallest-substring-of-a-string-containing-all-unique-characters-of-itself"}}}`

# Longest Substring With Non Repeating Characters

1. You are given a string. 2. You have to find the length of the longest substring of the given string that contains all non-repeating characters.

`{"id":"c6bfa29d-be9b-4ce2-9123-9e34e0feb36e","name":"Longest Substring With Non Repeating Characters","description":"1. You are given a string.\r\n2. You have to find the length of the longest substring of the given string that contains all non-repeating characters.","inputFormat":"A string","outputFormat":"A number representing the length of longest substring with unique characters.","constraints":"1 &lt;= length of string &lt;= 10^5","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\n\nint solution(string str){\n // write your code here\n}\n\nint main(){\n\tstring str;\n\tcin>>str;\n\tcout <<solution(str);\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String str) {\r\n\t\t// write your code here\r\n\t\t\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString str = scn.next();\r\n\t\tSystem.out.println(solution(str));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"aabcbcdbca","sampleOutput":"4\r\n","questionVideo":"https://www.youtube.com/embed/9Kc0eZBGL1U?end=13","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"aa00364a-2a79-46f9-b4d1-fdef27782250","name":"Longest Substring With Non Repeating Characters","slug":"longest-substring-with-non-repeating-characters","type":1}],"next":{"id":"bd3e3857-f817-4870-a336-bd819b1a6c4d","name":"Longest Substring With Non Repeating Characters MCQ","type":0,"slug":"longest-substring-with-non-repeating-characters-mcq"},"prev":{"id":"226e8d15-bc56-4516-ba18-cd01d32f7e40","name":"Smallest Substring Of A String Containing All Unique Characters Of Itself","type":3,"slug":"smallest-substring-of-a-string-containing-all-unique-characters-of-itself"}}}`

Editor

# Longest Substring With Non Repeating Characters

medium

1. You are given a string. 2. You have to find the length of the longest substring of the given string that contains all non-repeating characters.

## Constraints

1 <= length of string <= 10^5

## Format

A string

### Output

A number representing the length of longest substring with unique characters.

## Example

Sample Input

`.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}aabcbcdbca`

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}4 ```

Question Video

Discussions

Show Discussion

Related Resources