class Solution { var dic: [Character: Int] = [:] var length = 0 var maxLength = 0 func lengthOfLongestSubstring(_ s: String) -> Int { var st = 0 var dt = 0 for (dt, dtChar) in s.enumerated() { if let prevIndex = dic[dtChar], st 0 { maxLength = maxLength < len ? len : maxLength } } //print("\(dic)") return maxLength } }