Given N lists of strings, the task is to find the count of lists which are not a sublist of any other given lists.
Input: [[“hey”, “hi”, “hello”], [“hey”, “bye”], [“hey”, “hi”]]
The third list is a subset of the first list, hence the first and the second list are the required lists.
Input: [[“geeksforgeeks”, “geeks”], [“geeks”, “geeksforgeeks”]]
Explanation: Both the lists comprise of same set of strings.
Follow the steps below to solve the problem:
- First of all, enumerate all the possible strings in all vectors, i.e. assign them an integer.
- Then, use a Bitset for all individual lists to store the strings present in them.
- Compare the bitsets. If one of the bitsets is a subset of another, ignore that list. Otherwise insert the index of that list in a set.
- Print all the indices in the set.
Below code is the implementation of the above approach:
Time Complexity: O ( N * M )
Auxiliary Space: O ( N * M )
- Largest possible Subset from an Array such that no element is K times any other element in the Subset
- Find maximum subset sum formed by partitioning any subset of array into 2 partitions with equal sum
- Strings from an array which are not prefix of any other string
- Largest subset of rectangles such that no rectangle fit in any other rectangle
- Count of elements not divisible by any other elements of Array
- Check whether bitwise AND of a number with any subset of an array is zero or not
- Sum of maximum and minimum of Kth subset ordered by increasing subset sum
- Array with GCD of any of its subset belongs to the given array
- Check if any permutation of a number without any leading zeros is a power of 2 or not
- Check if there exists any sub-sequence in a string which is not palindrome
- Longest subarray in which absolute difference between any two element is not greater than X
- Construct a graph which does not contain any pair of adjacent nodes with same value
- Divide array into two arrays which does not contain any pair with sum K
- Check if bitwise AND of any subset is power of two
- Largest subset where absolute difference of any two element is a power of 2
- Print all possible combinations of the string by replacing '$' with any other digit from the string
- Minimize count of given operations required to make two given strings permutations of each other
- Count of elements which cannot form any pair whose sum is power of 2
- Count the nodes of a tree whose weighted string does not contain any duplicate characters
- Maximum in array which is at-least twice of other elements
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet