Delete to maximize unique substring
Input
longest_substring_after_one_deletion("abca")
Output
3
Delete the final 'a' to get 'abc' with longest unique substring length 3.
Full lesson preview
Given a string, optionally delete at most one character and find the length of the longest substring without repeating characters.
Problem statement
Task
Examples
Input
longest_substring_after_one_deletion("abca")
Output
3
Delete the final 'a' to get 'abc' with longest unique substring length 3.
Input format
Output format
Constraints
Samples
Input
longest_substring_after_one_deletion("eceba")
Output
4
Deleting the second 'e' yields a string where 'ecba' (or 'ceba') is length 4 with unique characters.