Commit a04dcac
Changed files (1)
2020
08
12
2020/08/12/main.rb
@@ -48,21 +48,21 @@ end
class Solution
def self.palindrome?(string)
- return "" if string.nil? || string.empty?
+ return false if string.nil? || string.empty?
- string == string.reverse ? string : ""
+ string == string.reverse
end
def self.run(string)
max = ""
-
for l in (0..string.size)
for r in (l+1..string.size)
- result = palindrome?(string[l..r])
- max = result if result.size > max.size
+ candidate = string[l..r]
+ if palindrome?(candidate) && candidate.size > max.size
+ max = candidate
+ end
end
end
-
max
end
end