Title: #76 - Minimum Window Substring - LeetCode JavaScript Solutions
Open Graph Title: #76 - Minimum Window Substring - LeetCode JavaScript Solutions
X Title: #76 - Minimum Window Substring - LeetCode JavaScript Solutions
Description: Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (includin...
Open Graph Description: Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (includin...
X Description: Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (includin...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/minimum-window-substring
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/minimum-window-substring","name":"#76 - Minimum Window Substring - LeetCode JavaScript Solutions","description":"Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (includin...","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 minWindow = function(s, t) {\n const values = new Array(128).fill(0);\n let [start, end] = [-Infinity, Infinity];\n\n for (let i = 0; i < t.length; i++) {\n values[t.charCodeAt(i)]++;\n }\n\n for (let i = 0, j = 0, total = t.length; i < s.length; i++) {\n if (values[s.charCodeAt(i)] > 0) {\n total--;\n }\n values[s.charCodeAt(i)]--;\n while (!total) {\n if (end - start > i - j) {\n [start, end] = [j, i];\n }\n values[s.charCodeAt(j)]++;\n if (values[s.charCodeAt(j)] > 0) {\n total++;\n }\n j++;\n }\n }\n\n return end !== Infinity ? s.slice(start, end + 1) : '';\n};","keywords":"LeetCode 76, #76 - Minimum Window Substring, 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/minimum-window-substring |
| 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/minimum-window-substring/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0076-minimum-window-substring.js |
| String | https://leetcodejavascript.com/tags/string |
| Hash Table | https://leetcodejavascript.com/tags/hash-table |
| Sliding Window | https://leetcodejavascript.com/tags/sliding-window |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow