Shortest unique substring

Write codeMedium25 min

Your task

Given a string s of lowercase letters (1 <= len(s) <= 1000), return the length of the SHORTEST substring that occurs exactly once in s. Such a substring always exists for non-empty s (the whole string occurs once unless it is fully periodic, in which case a longer-but-unique length is returned). Return that minimal unique length.

Examples

shortest_unique_substring_len(s: str) -> int
Example 1
Inputshortest_unique_substring_len("aabba")
Output2