Leetcode: Longest substring without repeating characters
You have exploited the space complexity.

def findLongestSubstring(inputString)
    hashMap = Hash.new
    longestSubstringLength = 0
    jIndex = 0
    iIndex = 0
    while(jIndex &lt; inputString.length)
        if(hashMap[inputString[jIndex]])
            iIndex = [iIndex, hashMap[inputString[jIndex]]].max
        end
        longestSubstringLength = [longestSubstringLength, jIndex-iIndex+1].max
        hashMap[inputString[jIndex]] = jIndex + 1
        jIndex = jIndex + 1
    end
    longestSubstringLength
end


This method makes use of HashMap which works efficiently in terms of complexity. Searching the element in HashMap works in O(1) and same goes for insertion. This way  you can reduce the complexity of your program