IBM Interview Question

data structures and algorithms like all substrings