FastPrepPaired Words That Share a Substring
Problems/Paired Words That Share a Substring

Paired Words That Share a Substring

DocuSign logoDocuSign● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report from April 2022 describes one of the candidate's final-round coding interviews. They got two word lists of equal length. For each position, they had to say with YES or NO whether the two words there have any substring in common. The candidate solved it with a hash map.

The report gives no limits, letters or examples, and does not say how long a shared substring must be. Here a single shared letter counts. The words use lowercase letters, with up to 1,000 pairs and 20,000 letters in total. You return the answers as a list instead of printing them. We wrote the examples.

Our version is about 90% the same as the reported question.

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 <= 1000
  • 1 <= a[i].length, b[i].length <= 5000
  • The total number of letters in all words of a and b together is at most 20000
  • Every word contains only lowercase English letters a to z

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

Interview reports that mention this question

  • DocuSign SWE Intern Interviews: 27 Experiences (Part 2 of 2)

DocuSign interview experiences

  • DocuSign SWE Intern OA Questions: 53 Experiences (Part 1 of 2)
All DocuSign interview questionsSee DocuSign hiring insights
Saved
class Solution {
    public String[] sharedSubstringAnswers(String[] a, String[] b) {
        // Write your code here.
    }
}
Checking account…