
g0001_0100.s0010_regular_expression_matching.solution.rb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
The newest version!
# #Hard #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming #Recursion
# #Udemy_Dynamic_Programming #Big_O_Time_O(m*n)_Space_O(m*n)
# #2023_11_14_Time_66_ms_(94.44%)_Space_211_MB_(36.11%)
# @param {String} s
# @param {String} p
# @return {Boolean}
def is_match(s, p)
converted = ''
split = p.split('')
split.each do |c|
if c == '*'
converted += '*'
elsif c == '.'
converted += '[a-z]'
else
converted += c
end
end
s.match(converted).to_s == s
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy