Question: Given two strings, determine if they share a common substring. A substring may be as small as one character. Example These share the common substring

Given two strings, determine if they share a common substring. A substring may be as small as one character.
Example
These share the common substring .
These do not share a substring.
Function Description
Complete the function twoStrings in the editor below.
twoStrings has the following parameter(s):
string s1: a string
string s2: another string
Returns
string: either YES or NO
Input Format
The first line contains a single integer , the number of test cases.
The following pairs of lines are as follows:
The first line contains string .
The second line contains string .
Constraints
and consist of characters in the range ascii[a-z].
Output Format
For each pair of strings, return YES or NO.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!