Find Set
Practice
5 (3 votes)
Algorithms
String searching
String algorithms
C++
Problem
74% Success 468 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given a set of \(N\) strings. Your task is to determine the minimum possible size of set \(S\) (\(S\) is a subset of \(N\) strings) such that it meets the following conditions:
- All \(N\) strings must be covered by set \(S\)
- A string \(P\) is said to be covered by the set \(S\) if either \(P\) exists in \(S\) or any substring of \(P\) exists in \(S\).
Input Format:
- First line contains an integer \(N\)
- Next \(N\) lines contains a string \(P\)
Output Format:
Print the minimum possible size of set \(S\) , which covers all the \(N\) strings.
Constraints:
\(1 \le N \le 500 \\ 1 \le |P| \le 500\)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
127 votes
Tags:
AlgorithmsApprovedKMP AlgorithmMediumOpenString Manipulation
Points:30
5 votes
Tags:
AlgorithmsDynamic ProgrammingKMP AlgorithmMediumString Manipulation
Points:20
47 votes
Tags:
ApprovedEasyMathOpen
Editorial
Login to unlock the editorial