All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g0001_0100.s0008_string_to_integer_atoi.solution.rb Maven / Gradle / Ivy

There is a newer version: 1.8
Show newest version
# #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