Question
Given a string s, count the number of distinct non-empty substrings of s. Insert every suffix of s into a trie; each trie node (other than the root) corresponds to exactly one distinct substring, so the answer is the total number of trie nodes created. Return that count. The string length is up to a few hundred, so the O(n^2) suffix-trie construction is acceptable.
count_distinct_substrings(s: str) → int["abab"]out7State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.