My Blog List

[Leetcode Solution] Plus One

Analysis 

  • Start from the least significant digit to find the first p that Digits[p] != 9
  • Plus one to this digit and change the digits from the least significant one to 0 until this digit
  • If all the digits are 9, then assign the first as 1, change all others as 0, and add one digit 0 at the end

Note

Code


UPDATED AT 2ND PASS

No comments:

Post a Comment

Enter you comment