Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Plus One LeetCode Java

// 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 :: plus one leetcode 
Java :: when does lockdown end 
Java :: jpa validation string only number 
Java :: append to file in java 
Java :: Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available jks 
Java :: table of any number in java 
Java :: bloomreach remove property 
Java :: java loop through string 
Java :: count the number of words in a string java 
Java :: Youtube video thumbnail not load in android 11 or above 
Java :: character classes in regex 
Java :: simulate mouse click java 
Java :: java remove from arraylist while iterating 
Java :: How to find the Levenshtein distance between two strings of characters using dynamic programming, in Java? 
Java :: toast.maketext error kotlin 
Java :: Date from String java11 
Java :: print hashtable in java 
Java :: fabricmc spawn item 
Java :: set precision in java 
Java :: american heavy tanks of ww2 
Java :: swing event enter key 
Java :: input array through scanner in java 
Java :: char variable java 
Java :: groovy string to json 
Java :: greatest common divisor java 
Java :: java jcheckbox get value 
Java :: how to instantiate hashmap in java 
Java :: Get the SUM of integers in List JAVA 
Java :: mockito verify not called 
Java :: startactivityforresult deprecated android 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =