Problem
https://leetcode.com/contest/weekly-contest-356/problems/shortest-string-that-contains-three-strings/
Optimal Space & Time Complexity
Solutions
東
Hao
YC
SOL
Supplement / Discussion
東
Hao
https://leetcode.com/problems/shortest-string-that-contains-three-strings/solutions/3840469/solving-shortest-string-that-contains-three-strings/
https://leetcode.com/problems/shortest-string-that-contains-three-strings/solutions/3836584/javascript-easy-and-clean-solution/
- Implement
merge() helper function: merge(merge(a, b), c) with Array.prototype.includes(), Array.prototype.indexOf() to find substring
- 6 possible string combination: [a, b, c], [a, c, b] …
- sort: smaller in length or lexicographically:
sort((a, b) => a.length - b.length || a.localeCompare(b))
YC
SOL