Practice Frequencies of Shortest Supersequences
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Frequencies of Shortest Supersequences
Problem Statement
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.
Source: Frequencies of Shortest Supersequences on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
words = ["ab","ba"]
[[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
# Example 2
words = ["aa","ac"]
[[2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
# Example 3
words = ["aa","bb","cc"]
[[2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
Constraints
Related LeetCode Problems
Practice more problems similar to Frequencies of Shortest Supersequences.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.