Created
December 3, 2022 08:54
-
-
Save ysinjab/14245044cd50ad68fbe3831e3a864896 to your computer and use it in GitHub Desktop.
66. Plus One
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
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