Video ID Generation (Generic)
Learn this problemProblem statement
TikTok is working to make the process of creating unique video IDs more efficient. A TikTok video ID is represented
as a string called idStream of length n, made up of the digits "0" to "9". TikTok
also has a list called videoIds, which contains m target video ID strings, each also made up of digits "0" to "9".
For each target video ID in videoIds, find the shortest part of idStream that contains all the
characters needed to form any possible arrangement (permutation) of the target string.
You will need to return an array of integers. The number at each position i in the array should be the length of the
shortest part of idStream that can include all characters of the ith string in the videoIds. If it is
impossible to create the target video ID from idStream, reutrn -1 for that position.
Function
videoIDGeneration(idStream: String, videoIds: String[]) → int[]Examples
Example 1
idStream = "064819848398"videoIds = ["088", "364", "07"]return = [7, 10, -1]Constraints
1 <= n <= 1051 <= m <= 2*1041 <= sum of the lengths of strings in videoIds <= 5*105All strings consist of characters '0' - '9' only.More Tiktok problems
- Can Reach the Exit with TeleportsOA · Seen Jul 2026
- Check Monotonic TriplesOA · Seen Jul 2026
- Shift Every K-th ConsonantOA · Seen Jul 2026
- Count Access Code PairsOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026
- Sort Matrix BordersOA · Seen Jul 2026
- Travel Distance on ScootersOA · Seen Jul 2026
- Validate 3x3 Digit WindowsOA · Seen Jul 2026