Skip to content

Instantly share code, notes, and snippets.

@ysinjab
Created December 3, 2022 08:54
Show Gist options
  • Save ysinjab/14245044cd50ad68fbe3831e3a864896 to your computer and use it in GitHub Desktop.
Save ysinjab/14245044cd50ad68fbe3831e3a864896 to your computer and use it in GitHub Desktop.
66. Plus One
class Solution:
def plusOne(self, digits: List[int]) -> List[int]:
for i in range(len(digits)-1, -1, -1):
if digits[i] == 9:
digits[i] = 0
else:
digits[i] += 1
return digits
return [1] + digits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment