1. Generate all substrings of the given string.2. Check if the substring has all unique characters.3. Return the max length of substrings with unique characters

Time Complexity: O(N^3), where N is string length Space Complexity: O(min(N, M)), as HashSet is used. N is the string length, and M is the size of the substring.

It only checks if the new character added to the substring is a duplicate rather than checking all substrings for duplicates. This avoids repeating tasks and increases efficiency.

Time Complexity: O(N^2), where N is string length Space Complexity: O(min(N, M)), as HashSet is used. N is the string length, and M is the size of the substring.