Hi guys,
you write that the time complexity is O(n^3):
For each k we can check for each j < k whether s(j+1,k) is a valid word and each such check requires O(k-j) time.
Do you mean that building substring takes O(n) time? Because the check itself is O(1) due to hash table, that’s why it’s not clear to me.