Skip to content

Instantly share code, notes, and snippets.

@mmanishh
Last active February 9, 2021 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmanishh/abf0c4d07d972d53f6de7ce55d1cb0dd to your computer and use it in GitHub Desktop.
Save mmanishh/abf0c4d07d972d53f6de7ce55d1cb0dd to your computer and use it in GitHub Desktop.
function commonSubString(arr1, arr2) {
for (const [i, value] of arr1.entries()) {
let isCommon = checkSubString(arr1[i], arr2[i])
console.log(isCommon)
}
}
function checkSubString(s1, s2) {
let shortStr;
let longStr;
if (s1.length < s2.length) {
shortStr = s1;
longStr = s2;
} else {
shortStr = s2;
longStr = s1;
}
for (let i = 0; i < shortStr.length; i++) {
if (longStr.indexOf(shortStr[i]) !== -1) {
return "YES"
}
}
return "NO"
}
let a = ["ab", "qw"]
let b = ["ad", "sdlfjgsldfjaafhjklashflaksdflaskdfaskdhfaskasdf"]
console.log(commonSubString(a, b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment