Skip to content

Instantly share code, notes, and snippets.

@eebasadre20
Created November 22, 2019 12:09
Show Gist options
  • Save eebasadre20/e0c2ccb0b309c3498e2ccd3289ac45d6 to your computer and use it in GitHub Desktop.
Save eebasadre20/e0c2ccb0b309c3498e2ccd3289ac45d6 to your computer and use it in GitHub Desktop.
LeetCode - Plus One Solution
# @param {Integer[]} digits
# @return {Integer[]}
def plus_one(digits)
( digits.join.to_i + 1 ).to_s.chars.map(&:to_i)
end
# first combine/join the array to make it one integer
# add ( + 1 )
# split the integer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment