Title: #1153 - String Transforms Into Another String - LeetCode JavaScript Solutions
Open Graph Title: #1153 - String Transforms Into Another String - LeetCode JavaScript Solutions
X Title: #1153 - String Transforms Into Another String - LeetCode JavaScript Solutions
Description: Given two strings str1 and str2 of the same length, determine whether you can transform str1 into str2 by doing zero or more conversions. In...
Open Graph Description: Given two strings str1 and str2 of the same length, determine whether you can transform str1 into str2 by doing zero or more conversions. In...
X Description: Given two strings str1 and str2 of the same length, determine whether you can transform str1 into str2 by doing zero or more conversions. In...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/string-transforms-into-another-string
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/string-transforms-into-another-string","name":"#1153 - String Transforms Into Another String - LeetCode JavaScript Solutions","description":"Given two strings str1 and str2 of the same length, determine whether you can transform str1 into str2 by doing zero or more conversions. In...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {string} str1\n * @param {string} str2\n * @return {boolean}\n */\nvar canConvert = function(str1, str2) {\n if (str1 === str2) return true;\n\n const mapping = new Map();\n const uniqueCharsInStr2 = new Set();\n for (let i = 0; i < str1.length; i++) {\n const char1 = str1[i];\n const char2 = str2[i];\n\n if (mapping.has(char1)) {\n if (mapping.get(char1) !== char2) {\n return false;\n }\n } else {\n mapping.set(char1, char2);\n }\n\n uniqueCharsInStr2.add(char2);\n }\n\n return uniqueCharsInStr2.size < 26;\n};","keywords":"LeetCode 1153, #1153 - String Transforms Into Another String, Hard, 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/string-transforms-into-another-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/string-transforms-into-another-string/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/1153-string-transforms-into-another-string.js |
| String | https://leetcodejavascript.com/tags/string |
| Hash Table | https://leetcodejavascript.com/tags/hash-table |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow