-
-
Save havenwood/1c3bb9aa53fcbc9e291b to your computer and use it in GitHub Desktop.
Longest Substring Without Repeating Characters
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
def lols s | |
s.size.downto(1).find do |n| | |
s.each_char.each_cons(n).any? do |chars| | |
!chars.uniq! | |
end | |
end | |
end | |
%w[abcabcbb bbbbb foobar].map &method(:lols) #=> [3, 1, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment