#3435
Frequencies of Shortest Supersequences
hard · 22.1% accepted · 28 likes · top 2%
array · string · bit manipulation · graph theory · topological sort · enumeration
Description
You are given an array of strings words. Find all shortest common supersequences (SCS) of words that are not permutations of each other.
A shortest common supersequence is a string of minimum length that contains each string in words as a subsequence.
Return a 2D array of integers freqs that represent all the SCSs. Each freqs[i] is an array of size 26, representing the frequency of each letter in the lowercase English alphabet for a single SCS. You may return the frequency arrays in any order.
Solution