Company: grid-hirepro_28thjuly
Difficulty: medium
Repeated Keyword Fragments You are given a list of N keywords. A fragment is any contiguous substring of a keyword. Only fragments of length **at least 3 ** matter. A fragment is repeated when it occurs in at least two different keywords of the list. Different keywords means different positions in the list: if the same word is listed twice, the two copies count as two keywords. Several occurrences inside one keyword count as one keyword only. Complete the function solve(n, keywords) , which returns every distinct repeated fragment, sorted in ascending lexicographic order. Input Format The first line contains an integer N , the number of keywords. The second line contains the N keywords, separated by single spaces. Output Format Print the returned fragments on one line, separated by single spaces. Each fragment is printed once. Constraints 2 <= N <= 200 *(inferred -- the source allows N = 1 , but a single keyword can never have a repeated fragment)* 1 <= length of each keyword