Repeated Keyword Fragments

Company: grid-hirepro_28thjuly

Difficulty: medium

Problem Statement

Repeated Keyword Fragments You are given N keywords (strings). Find every contiguous substring of length at least 3 that occurs in at least two different keywords from the list. Print all such substrings, each one only once, in ascending lexicographic order, space-separated on a single line. If no such substring exists, print an empty line. Input Format The first line contains the integer N , the number of keywords. The second line contains the N keywords, separated by single spaces. Output Format The first and only line of output must contain every qualifying substring (length >= 3 , appearing in at least two different keywords), each printed once, sorted in ascending lexicographic (dictionary) order and separated by a single space. Print an empty line if no substring qualifies. Constraints 1 <= N <= 200 Each keyword has length between 1 and 50 and consists only of lowercase English letters. Sample Input 1 4 hakuna kunafa kubernetes fridge Sample Output 1 kun kuna una Explana