package com.fishercoder.solutions;

/**
 * 66. Plus One
 *
 * Given a non-empty array of digits representing a non-negative integer, plus one to the integer.
 * The digits are stored such that the most significant digit is at the head of the list,
 * and each element in the array contain a single digit.
 *
 * You may assume the integer does not contain any leading zero, except the number 0 itself.
 *
 * Example 1:
 * Input: [1,2,3]
 * Output: [1,2,4]
 * Explanation: The array represents the integer 123.
 *
 * Example 2:
 * Input: [4,3,2,1]
 * Output: [4,3,2,2]
 * Explanation: The array represents the integer 4321.
 */
public class _66 {

  public static class Solution1 {
      /**credit: https://leetcode.com/problems/plus-one/discuss/24082/My-Simple-Java-Solution*/
    public int[] plusOne(int[] digits) {
        int len = digits.length;
        for (int i = len - 1; i >= 0; i--) {
            if (digits[i] < 9) {
                digits[i]++;
                return digits;
            }
            digits[i] = 0;
        }
        int[] newNumber = new int[len + 1];
        newNumber[0] = 1;
        return newNumber;
    }
  }
}

@@ -33,598 +33,8 @@
 s;%0A%0A
-/**%0A * 66. Plus One%0A *%0A * Given a non-empty array of digits representing a non-negative integer, plus one to the integer.%0A * The digits are stored such that the most significant digit is at the head of the list,%0A * and each element in the array contain a single digit.%0A *%0A * You may assume the integer does not contain any leading zero, except the number 0 itself.%0A *%0A * Example 1:%0A * Input: %5B1,2,3%5D%0A * Output: %5B1,2,4%5D%0A * Explanation: The array represents the integer 123.%0A *%0A * Example 2:%0A * Input: %5B4,3,2,1%5D%0A * Output: %5B4,3,2,2%5D%0A * Explanation: The array represents the integer 4321.%0A */%0A
 publ
@@ -49,16 +49,18 @@
  _66 %7B%0A%0A
+  
   public
@@ -95,11 +95,25 @@
     
+  
 /**
+%0A         * 
 cred
@@ -196,15 +196,29 @@
 tion
-*/%0A
+%0A         */%0A   
     
+ 
 publ
@@ -246,24 +246,28 @@
 %5D digits) %7B%0A
+    
         int 
@@ -295,16 +295,20 @@
         
+    
 for (int
@@ -348,16 +348,20 @@
         
+ 
+   
 if (digi
@@ -381,32 +381,36 @@
                 
+    
 digits%5Bi%5D++;%0A   
@@ -406,16 +406,20 @@
 s%5Bi%5D++;%0A
+    
         
@@ -445,34 +445,42 @@
 ts;%0A            
-%7D%0A
+    %7D%0A    
             digi
@@ -490,34 +490,42 @@
 i%5D = 0;%0A        
+  
-%7D%0A
+  %7D%0A    
         int%5B%5D ne
@@ -552,16 +552,20 @@
 n + 1%5D;%0A
+    
         
@@ -586,24 +586,28 @@
  1;%0A        
+    
 return newNu
@@ -616,16 +616,22 @@
 er;%0A    
-%7D%0A
+    %7D%0A  
   %7D%0A%7D%0A

refactor 66