Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

plus one

// 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 :: java test if a string is a int 
Java :: java get domain from url 
Java :: java get amount of enums 
Java :: java write string 
Java :: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory 
Java :: How to find a target value within a binary search tree, in Java? 
Java :: lakshya 
Java :: file to multipartfile in java 
Java :: initialize hashset java 
Java :: Spring Boot Hibernate remove underscore naming strategy 
Java :: change color of text in textview android 
Java :: android action key 
Java :: how to build a java main menu 
Java :: java max from 3 parameters 
Java :: how to get date android studio 
Java :: Date from String java7 
Java :: array ausgeben java 
Java :: java public static void main 
Java :: spring mvc get all request parameters 
Java :: spinner get item text 
Java :: formartted string java 
Java :: android studio get string from strings.xml 
Java :: arrays.aslist.add 
Java :: implement graph in java example 
Java :: spigot remove every entity 
Java :: java convert list to page 
Java :: android studio remove notification bar 
Java :: calculate mean from arraylist jaca 
Java :: char equals java 
Java :: size of queue in java 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =