Paired Words That Share a Substring
Updated
Problem statement
You are given two lists of words, a and b, with the same length n. For each position i, decide whether the words a[i] and b[i] have a substring in common.
A substring is one or more consecutive letters of a word. A single letter counts as a substring.
Return a list of n answers. Answer i is "YES" if some substring appears in both a[i] and b[i], and "NO" otherwise. Only the two words at the same position are compared with each other.
Function
sharedSubstringAnswers(a: String[], b: String[]) → String[]Examples
Example 1
a = ["sign","date","ink"]b = ["stamp","form","pen"]return = ["YES","NO","YES"]Pair 0: "sign" and "stamp" both contain s, so the answer is "YES". Pair 1: "date" uses d, a, t, e and "form" uses f, o, r, m. No letter is in both, so no substring can be in both, and the answer is "NO". Pair 2: "ink" and "pen" both contain n, so "YES".
Example 2
a = ["note","zip"]b = ["tone","quack"]return = ["YES","NO"]Pair 0: "note" and "tone" have no two-letter piece in common ("no", "ot", "te" against "to", "on", "ne"), but they share single letters such as o. One letter is a substring, so the answer is "YES". Pair 1: z, i, p against q, u, a, c, k: nothing in common, so "NO".
Example 3
a = ["aaaa"]b = ["bbbb"]return = ["NO"]The only letter in the first word is a and the only letter in the second is b. They share nothing, so the answer is "NO".
Constraints
1 <= a.length == b.length <= 10001 <= a[i].length, b[i].length <= 5000- The total number of letters in all words of
aandbtogether is at most20000 - Every word contains only lowercase English letters
atoz
More DocuSign Onsite Interview questions
- Count Binary SubstringsONSITE INTERVIEW · Seen Sep 2026
- Two Positions That Add Up to a TargetPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Compress Consecutive Integer RangesONSITE INTERVIEW · Seen Aug 2026
- JSON Schema Object ValidatorONSITE INTERVIEW · Seen Aug 2026
- Most Transactions Kept Without Going NegativeONSITE INTERVIEW · Seen May 2025
- Three-Part Splits With a Light MiddleONSITE INTERVIEW · Seen May 2025
- Combine Two Sorted Lists Into OneONSITE INTERVIEW · Seen Apr 2022
- Exact Palindrome CheckPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
- Reverse the Characters of a TextPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
- Reverse the Order of a Linked ListONSITE INTERVIEW · Seen Feb 2020
Similar questions at other companies
- Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
- Count a User's Actions in an Event LogMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
- Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
- First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- Longest Dictionary Word from Nine LettersGoogle · ONSITE INTERVIEWGoogle interview questions
- Minimum Replacements to Make Two Strings AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Isomorphic StringsRemitly · ONSITE INTERVIEWRemitly interview questions
- Check AnagramsDeloitte · ONSITE INTERVIEWDeloitte interview questions