Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

plus one leetcode

// https://leetcode.com/problems/plus-one/

class Solution {
    public int[] plusOne(int[] digits) {
        for (int i = digits.length -1 ; i >= 0; i-- ){
            if (digits[i] < 9){
                digits[i]++;
                return digits;
            }
            digits[i] = 0;
        }
        
        int[] result = new int[digits.length + 1];
        result[0] = 1;
        return result;
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: regex validation for special characters in java 
Java :: java split array into two 
Java :: how to get color from color file in adroid studio 
Java :: java console write 
Java :: scan.nextline not waiting for input 
Java :: how to set audio of a java sound clip 
Java :: set vs list java 
Java :: javafx event resize 
Java :: java create set with values 
Java :: int a=08 java 
Java :: print arraylist java 
Java :: jersey test dependency 
Java :: rates api 
Java :: get id of html tag by class 
Java :: 2 power 8 in java 
Java :: java initialize float to zero 
Java :: check if string has a valid number java 
Java :: check if object in array java 
Java :: decimal up to 6 places in java 
Java :: how to read a .json from web api java 
Java :: onclicklistener in android studio 
Java :: minecraft java arguments 
Java :: java read each lines in file 
Java :: making android activity fullscreen android studio 
Java :: java word count 
Java :: testException = com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field 
Java :: array to arraylist 
Java :: how-to-check-internet-connection-in-android 
Java :: encode file to base64 java 
Java :: how to loop through a 2d array java 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =