
g0001_0100.s0008_string_to_integer_atoi.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
# #Medium #Top_Interview_Questions #String #2023_11_14_Time_67_ms_(67.26%)_Space_211.1_MB_(42.48%)
# @param {String} s
# @return {Integer}
def my_atoi(s)
max = (2 ** 31) - 1
min = (-2 ** 31)
return s.to_i if s.to_i <= max && s.to_i >= min
s.to_i < min ? min : max
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy