Last active
February 9, 2021 13:53
-
-
Save mmanishh/abf0c4d07d972d53f6de7ce55d1cb0dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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