Created
November 22, 2019 12:09
-
-
Save eebasadre20/e0c2ccb0b309c3498e2ccd3289ac45d6 to your computer and use it in GitHub Desktop.
LeetCode - Plus One Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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