Clean Up Captions
Learn this problemProblem statement
As a TikTok developer, you're working on a project to clean up captions and optimize storage. With millions of captions and hashtags circulating the platform, your task is to detect any overlap between captions on the for_you feed and the following feed. But it's not just about finding common words or hashtags; you need to identify any common substring between the two!
You are given two lists of captions — one from the for_you feed and another from the following feed. For each corresponding pair of captions, your job is to check if any substring appears in both captions. If a common substring is found, you should output "YES"; otherwise, output "NO."
Function
optimizeStorageByCleaning(for_you: String[], following: String[]) → String[]
Complete the function optimizeStorageByCleaning in the editor.
optimizeStorageByCleaning has the following parameter(s):
String for_you[n]: an array of stringsString following[n]: an array of strings
Returns
String answers[n]: An array of strings where each element is either "YES" or "NO". "YES" indicates that a common substring exists between the corresponding logs in for_you and following, while "NO" indicates that no common substring exists.
Examples
Example 1
for_you = ["ba", "md", "rj"]following = ["af", "ee", "rf"]return = ["YES", "NO", "YES"]
Constraints
- All the strings consist of lowercase English letters only, ascii[a-z].
- |for_you| = |following|
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