Created
October 11, 2017 06:40
-
-
Save roger35972134/7a6f81c784fc5e11c1a10a19aa41f2a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @param {String} s | |
# @return {Integer} | |
def length_of_longest_substring(s) | |
max = 0 | |
for i in 0..s.length-1 | |
check = Array.new(256, false) | |
for j in i..s.length-1 | |
index = s[j].ord | |
if check[index] == false | |
check[index] = true | |
else | |
break | |
end | |
end | |
if check.count(true) > max | |
max = check.count(true) | |
end | |
end | |
max | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment