66. Plus One Easy

@problem@discussion
#Array#Math



1/**
2 * [66] Plus One
3 *
4 * You are given a large integer represented as an integer array digits, where each digits[i] is the i^th digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's.
5 * Increment the large integer by one and return the resulting array of digits.
6 *  
7 * Example 1:
8 * 
9 * Input: digits = [1,2,3]
10 * Output: [1,2,4]
11 * Explanation: The array represents the integer 123.
12 * Incrementing by one gives 123 + 1 = 124.
13 * Thus, the result should be [1,2,4].
14 * 
15 * Example 2:
16 * 
17 * Input: digits = [4,3,2,1]
18 * Output: [4,3,2,2]
19 * Explanation: The array represents the integer 4321.
20 * Incrementing by one gives 4321 + 1 = 4322.
21 * Thus, the result should be [4,3,2,2].
22 * 
23 * Example 3:
24 * 
25 * Input: digits = [9]
26 * Output: [1,0]
27 * Explanation: The array represents the integer 9.
28 * Incrementing by one gives 9 + 1 = 10.
29 * Thus, the result should be [1,0].
30 * 
31 *  
32 * Constraints:
33 * 
34 * 	1 <= digits.length <= 100
35 * 	0 <= digits[i] <= 9
36 * 	digits does not contain any leading 0's.
37 * 
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/plus-one/
42// discuss: https://leetcode.com/problems/plus-one/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47    pub fn plus_one(digits: Vec<i32>) -> Vec<i32> {
48        vec![]
49    }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57
58    #[test]
59    fn test_66() {
60    }
61}
62


Back
© 2025 bowen.ge All Rights Reserved.