Title: #791 - Custom Sort String - LeetCode JavaScript Solutions
Open Graph Title: #791 - Custom Sort String - LeetCode JavaScript Solutions
X Title: #791 - Custom Sort String - LeetCode JavaScript Solutions
Description: S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We w...
Open Graph Description: S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We w...
X Description: S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We w...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/custom-sort-string
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/custom-sort-string","name":"#791 - Custom Sort String - LeetCode JavaScript Solutions","description":"S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We w...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {string} S\n * @param {string} T\n * @return {string}\n */\nvar customSortString = function(S, T) {\n const order = S.split('').reduce((o, k, i) => ({...o, [k]: i}), {});\n return T.split('').sort((a, b) => (order[a] || 0) - (order[b] || 0)).join('');\n};","keywords":"LeetCode 791, #791 - Custom Sort String, Medium, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/custom-sort-string |
| twitter:image | https://leetcodejavascript.com/og-image.jpg |
| twitter:creator | @joshcrozier |
| theme-color | #1f2937 |
Links:
| LeetCodeJavascript.com | https://leetcodejavascript.com/ |
| Star on GitHub | https://github.com/JoshCrozier/leetcode-javascript |
| Back to all solutions | https://leetcodejavascript.com |
| View on LeetCode | https://leetcode.com/problems/custom-sort-string/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0791-custom-sort-string.js |
| String | https://leetcodejavascript.com/tags/string |
| Hash Table | https://leetcodejavascript.com/tags/hash-table |
| Sorting | https://leetcodejavascript.com/tags/sorting |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow