-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-to-array-form-of-integer.html
42 lines (32 loc) · 1.27 KB
/
add-to-array-form-of-integer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<p>The <strong>array-form</strong> of an integer <code>num</code> is an array representing its digits in left to right order.</p>
<ul>
<li>For example, for <code>num = 1321</code>, the array form is <code>[1,3,2,1]</code>.</li>
</ul>
<p>Given <code>num</code>, the <strong>array-form</strong> of an integer, and an integer <code>k</code>, return <em>the <strong>array-form</strong> of the integer</em> <code>num + k</code>.</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> num = [1,2,0,0], k = 34
<strong>Output:</strong> [1,2,3,4]
<strong>Explanation:</strong> 1200 + 34 = 1234
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> num = [2,7,4], k = 181
<strong>Output:</strong> [4,5,5]
<strong>Explanation:</strong> 274 + 181 = 455
</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> num = [2,1,5], k = 806
<strong>Output:</strong> [1,0,2,1]
<strong>Explanation:</strong> 215 + 806 = 1021
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= num.length <= 10<sup>4</sup></code></li>
<li><code>0 <= num[i] <= 9</code></li>
<li><code>num</code> does not contain any leading zeros except for the zero itself.</li>
<li><code>1 <= k <= 10<sup>4</sup></code></li>
</ul>