66. Plus One
Input: digits = [1,2,3]
Output: [1,2,4]
Explanation: The array represents the integer 123.Input: digits = [4,3,2,1]
Output: [4,3,2,2]
Explanation: The array represents the integer 4321.Input: digits = [0]
Output: [1]# @param {Integer[]} digits
# @return {Integer[]}
def plus_one(digits)
new_int = digits.join('').to_i
new_int += 1
digits = new_int.to_s.split('').map(&:to_i)
p digits
endLast updated