logo CodeStepByStep logo


Language/Type: C# algorithms interview strings
Related Links:

Write a method named LongestUniqueString that accepts a string as a parameter and returns an integer representing the longest substring that can be formed from it without any repeated characters. For example, the call of LongestUniqueString("abcabcab") should return 3 because its longest such substring is "abc". The call of LongestUniqueString("aaaa") should return 1 because its longest such substring is "a". The call of LongestUniqueString("abbbcbbbacddb") should return 4 because its longest such substring is "bacd". ("abcd" or "abcde" are not valid because they are subsequences, not substrings.)

If the string is empty, return 0. You may assume that the string contains only standard ASCII characters (no extended Unicode character values).

Method: Write a C# method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.