JavaScript Greedy Solution with clean explaination
\nvar shortestSuperstring = function(arr) {\n  while (arr.length > 1) {\n    let maxCommonLength = 0;\n    let maxCommonString = arr[0] + arr[1];\n    let maxCo
```\nvar shortestSuperstring = function(arr) {\n  while (arr.length > 1) {\n    let maxCommonLength = 0;\n    let maxCommonString = arr[0] + arr[1];\n    let maxCommonWords = [arr[0], arr[1]];\n    for (let i = 0; i < arr.length - 1; i++) {\n      for (let j = i + 1; j < arr.length; j++) {\n        const {commonLength, commonString} = checkCommonPair(arr[i], arr[j])\n        /**\n         * Updates only when find a common string and the common length is not\n         * less than the max common length.\n         */\n        if (commonString && commonLength >= maxCommonLength) {\n          maxCommonLength = commonLength;\n          maxCommonString = commonString;\n          maxCommonWords = [arr[i], arr[j]];\n        }\n      }\n    }\n    /** Removes the checked word. */\n    arr = arr.filter(word => word !== maxCommonWords[0] &&\n      word !== maxCommonWords[1]);\n    /** Adds the ideal common string at the head. */\n    arr.unshift(maxCommonString);\n  }\n  return arr[0];\n};\n\n/** Checks the length and pair string of the pair. */\nvar checkCommonPair = function(s1, s2) {\n  let maxCommonLength = 0;\n  let commonString = \'\';\n  /** Makes sure s1 is always the shorter one. */\n  if (s1.length > s2.length) s1, s2 = s2, s1;\n\n  /** Checks s1 suffix and s2 prefix. */\n  for (let stringLength = 1; stringLength < s1.length; stringLength++) {\n    const s1Suffix = s1.substring(s1.length - stringLength);\n    const s2Prefix = s2.substring(0, stringLength);\n    if (s1Suffix === s2Prefix && stringLength > maxCommonLength) {\n      maxCommonLength = stringLength;\n      commonString = s1 + s2.substring(stringLength);\n    }\n  }\n\n  /** Checks s1 prefix and s2 suffix. */\n  for (let stringLength = 1; stringLength < s1.length; stringLength++) {\n    const s1Prefix = s1.substring(0, stringLength);\n    const s2Suffix = s2.substring(s2.length - stringLength);\n    if (s1Prefix === s2Suffix && stringLength > maxCommonLength) {\n      if (stringLength > maxCommonLength) {\n        maxCommonLength = stringLength;\n        commonString = s2 + s1.substring(stringLength);\n      }\n    }\n  }\n\n  return {\n    commonLength: maxCommonLength,\n    commonString,\n  };\n}\n```
[]