https://practice.geeksforgeeks.org/problems/longest-distinct-characters-in-string/0/?track=string-interview
what is wrong in my approach?
https://ide.geeksforgeeks.org/yPteq5BPnG
Longest distinct characters in a string
you have to find the longest substring which has all characters distinct.
For eg: you have test 2 cases
2
aaaaastha : your output will be 5 but the expected output is 4.
since the substring “asth” has 4 distinct characters.
abbced : your output will be 2 but correct output is 4 as u can take “bced” susbstring which has 4 distinct characters.
You are only checking if the current character is same as just previous value .