Distinct substrings

Write codeMedium28 min

Your task

Given a string s, return the number of distinct non-empty substrings of s. Two substrings are the same if they are equal as strings (positions don't matter). 1 <= len(s) <= 1000, lowercase letters. Example: 'aba' has substrings a, b, ab, ba, aba = 5 distinct.

Examples

count_distinct_substrings(s: str) -> int
Example 1
Inputcount_distinct_substrings("aba")
Output5