Skip to main content

Count Distinct Substrings

Challenge on lesson: Checkpoint — Distinct Substrings

CHALLENGE
Difficulty: advanced+25 XP

**Problem.** Each line: a string s (read until EOF). Print one integer per line: the number of DISTINCT non-empty substrings of s. **Constraints:** up to 20 lines; 1 ≤ |s| ≤ 2000; lowercase letters. Suffix array + Kasai LCP; the O(n^2)-substrings brute force is the graded wrong answer (time AND memory).

Back to lesson: Checkpoint — Distinct Substrings