## Problem <br> https://leetcode.com/contest/weekly-contest-356/problems/shortest-string-that-contains-three-strings/ :::spoiler **Optimal Space & Time Complexity** ``` - Time complexity: - Space complexity: ``` ::: <br> <hr/> ## Solutions :::spoiler 東 ```javascript= ``` ::: <br> :::spoiler Hao ```javascript= ``` ::: <br> :::spoiler YC ```javascript= ``` ::: <br> :::spoiler SOL ```javascript= ``` ::: --- ## 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/ 1. Implement `merge()` helper function: `merge(merge(a, b), c)` with `Array.prototype.includes()`, `Array.prototype.indexOf()` to find substring 2. 6 possible string combination: [a, b, c], [a, c, b] ... 3. sort: smaller in length or lexicographically: `sort((a, b) => a.length - b.length || a.localeCompare(b))` ### YC ### SOL