Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Plus One 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 :: android how to start a new activity on button click 
Java :: material design android dependency androidx 
Java :: foreach not applicable to type - binary tree sort 
Java :: dialog box in java swing 
Java :: java last element in array 
Java :: method to check parameters in java 
Java :: Which API provides a lightweight solution for GUI components? 
Java :: java initialize map with values in one line 
Java :: java stream to list 
Java :: address book java program to add edit and delete 
Java :: spring jpa tree structure 
Java :: android java date from internet 
Java :: java new arraylist of n zeros 
Java :: immagini java 
Java :: localdatetime to timestamp 
Java :: Date from String java3 
Java :: print line number java 
Java :: android view to bitmap 
Java :: java import set and hashset 
Java :: java round double to 2 decimals 
Java :: java event enter key 
Java :: react native android gif 
Java :: adding 2 variable in java 
Java :: java delete files 
Java :: find shortest string in array java 
Java :: java int to hex 
Java :: how to initialize an array in java 
Java :: java set label color 
Java :: convert datetime to custom format in java 8 
Java :: public static void main(string args) 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =