`{"id":"19ce5211-e9e4-4680-abce-853c39ba47a6","name":"Count Of Substrings Having All Unique Characters","description":"1. You are given a string.\r\n2. You have to find the count of valid substrings of the given string.\r\n3. Valid substring is defined as a substring that has all unique characters. ","inputFormat":"A string","outputFormat":"A number representing the count of substrings having all unique characters.","constraints":"1 &lt;= length of string &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\n#include<string>\n#include<map>\nusing namespace std;\nint lengthOfLongestSubstring (string &s) {\n //Write your code here \n }\n \nint main(int argc,char** argv){\n string s;\n cin>>s;\n cout<<lengthOfLongestSubstring(s)<<endl;\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":"easy","sampleInput":"aabcbcdbca","sampleOutput":"24\r\n","questionVideo":"https://www.youtube.com/embed/Auk0E3E8G7c?end=69","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":"1623dcd3-8bbf-4662-964b-bfc522479908","name":"Count Of Substrings Having All Unique Characters","slug":"count-of-substrings-having-all-unique-characters","type":1}],"next":{"id":"c51ab971-bdb7-4e68-8ea6-63e4b2966c89","name":"Count Of Substrings Having All Unique Characters MCQ","type":0,"slug":"count-of-substrings-having-all-unique-characters-mcq"},"prev":{"id":"0d7abd96-0cfb-4ffd-a166-6bae65d36522","name":"Longest Substring With Non Repeating Characters","type":3,"slug":"longest-substring-with-non-repeating-characters"}}}`

# Count Of Substrings Having All Unique Characters

1. You are given a string. 2. You have to find the count of valid substrings of the given string. 3. Valid substring is defined as a substring that has all unique characters.

`{"id":"19ce5211-e9e4-4680-abce-853c39ba47a6","name":"Count Of Substrings Having All Unique Characters","description":"1. You are given a string.\r\n2. You have to find the count of valid substrings of the given string.\r\n3. Valid substring is defined as a substring that has all unique characters. ","inputFormat":"A string","outputFormat":"A number representing the count of substrings having all unique characters.","constraints":"1 &lt;= length of string &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\n#include<string>\n#include<map>\nusing namespace std;\nint lengthOfLongestSubstring (string &s) {\n //Write your code here \n }\n \nint main(int argc,char** argv){\n string s;\n cin>>s;\n cout<<lengthOfLongestSubstring(s)<<endl;\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":"easy","sampleInput":"aabcbcdbca","sampleOutput":"24\r\n","questionVideo":"https://www.youtube.com/embed/Auk0E3E8G7c?end=69","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":"1623dcd3-8bbf-4662-964b-bfc522479908","name":"Count Of Substrings Having All Unique Characters","slug":"count-of-substrings-having-all-unique-characters","type":1}],"next":{"id":"c51ab971-bdb7-4e68-8ea6-63e4b2966c89","name":"Count Of Substrings Having All Unique Characters MCQ","type":0,"slug":"count-of-substrings-having-all-unique-characters-mcq"},"prev":{"id":"0d7abd96-0cfb-4ffd-a166-6bae65d36522","name":"Longest Substring With Non Repeating Characters","type":3,"slug":"longest-substring-with-non-repeating-characters"}}}`

Editor

Loading...

# Count Of Substrings Having All Unique Characters

easy

1. You are given a string. 2. You have to find the count of valid substrings of the given string. 3. Valid substring is defined as a substring that has all unique characters.

## Constraints

1 <= length of string <= 10^5

## Format

A string

### Output

A number representing the count of substrings having all 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;}24 ```

Question Video

Discussions

Show Discussion

Related Resources