Closed LLLarry closed 3 years ago
function maxLength (str) { let maxValue = 0 function tt (index) { let newStr = '' for (let i = index; i < str.length; i++) { if (!newStr.includes(str[i])) { newStr += str[i] maxValue = Math.max(maxValue, newStr.length) } else { if (index + 1 <= str.length) { tt(index + 1) } } } } tt(0) return maxValue }
function maxLength (str) { let maxValue = 0 function tt (index) { let newStr = '' for (let i = index; i < str.length; i++) { if (!newStr.includes(str[i])) { newStr += str[i] maxValue = Math.max(maxValue, newStr.length) } else { if (index + 1 <= str.length) { tt(index + 1) } } } } tt(0) return maxValue }