Skip to content

Commit 6e29028

Browse files
committed
Add solution #989
1 parent 820ffe6 commit 6e29028

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

0989-add-to-arrayform-of-integer.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* 989. Add to Array-Form of Integer
3+
* https://leetcode.com/problems/add-to-array-form-of-integer/
4+
* Difficulty: Easy
5+
*
6+
* For a non-negative integer X, the array-form of X is
7+
* an array of its digits in left to right order.
8+
* For example, if X = 1231, then the array form is [1,2,3,1].
9+
*
10+
* Given the array-form A of a non-negative integer X,
11+
* return the array-form of the integer X+K.
12+
*/
13+
14+
/**
15+
* @param {number[]} A
16+
* @param {number} K
17+
* @return {number[]}
18+
*/
19+
var addToArrayForm = function(A, K) {
20+
return String(BigInt(A.join('')) + BigInt(K)).split('');
21+
};

0 commit comments

Comments
 (0)