Longest Substring Of All Vowels in Order LeetCode solution in JavaScript
1/**2* @param {string} word3* @return {number}4*/5var longestBeautifulSubstring = function (word) {6let obj = { a: 1, e: 2, i: 3, o: 4, u: 5 };7let seq = 0;8let maxstrcount = 0,9strcount = "";10for (let i = 0; i <= word.length; i++) {11if (seq <= obj[word[i]]) {12strcount += word[i];13seq = obj[word[i]];14} else {15let set = new Set();16for (let i = 0; i < strcount.length; i++) {17set.add(strcount[i]);18}19if (set.size == 5) {20maxstrcount = Math.max(strcount.length, maxstrcount);21}22if (i < word.length - 1) i--;23strcount = "";24seq = 0;25}26}27return maxstrcount;28};