bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 66. Plus One

66. Plus One

Leetcode Solutions

Schoolbook Addition with Carry

  1. Start from the end of the digits array and iterate backwards.
  2. If the current digit is less than 9, increment it by one and return the digits array.
  3. If the current digit is 9, set it to 0 and move to the next more significant digit.
  4. If all digits have been set to 0 (meaning all were 9), append a 1 at the beginning of the array.
  5. Return the modified digits array.
UML Thumbnail

Convert to Integer and Add

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...