989. Add to Array-Form of Integer Easy

@problem@discussion
#Array#Math



1/**
2 * [989] Add to Array-Form of Integer
3 *
4 * The array-form of an integer num is an array representing its digits in left to right order.
5 * 
6 * 	For example, for num = 1321, the array form is [1,3,2,1].
7 * 
8 * Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.
9 *  
10 * Example 1:
11 * 
12 * Input: num = [1,2,0,0], k = 34
13 * Output: [1,2,3,4]
14 * Explanation: 1200 + 34 = 1234
15 * 
16 * Example 2:
17 * 
18 * Input: num = [2,7,4], k = 181
19 * Output: [4,5,5]
20 * Explanation: 274 + 181 = 455
21 * 
22 * Example 3:
23 * 
24 * Input: num = [2,1,5], k = 806
25 * Output: [1,0,2,1]
26 * Explanation: 215 + 806 = 1021
27 * 
28 *  
29 * Constraints:
30 * 
31 * 	1 <= num.length <= 10^4
32 * 	0 <= num[i] <= 9
33 * 	num does not contain any leading zeros except for the zero itself.
34 * 	1 <= k <= 10^4
35 * 
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/add-to-array-form-of-integer/
40// discuss: https://leetcode.com/problems/add-to-array-form-of-integer/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45    pub fn add_to_array_form(num: Vec<i32>, k: i32) -> Vec<i32> {
46        vec![]
47    }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54    use super::*;
55
56    #[test]
57    fn test_989() {
58    }
59}
60


Back
© 2025 bowen.ge All Rights Reserved.