You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a non-negative integer X, the array-form of X is an array of its digits in left to right order. For example, if X = 1231, then the array form is [1,2,3,1].
Given the array-form A of a non-negative integer X, return the array-form of the integer X+K.
/****************************************/
class Solution {
public:
vector<int> addToArrayForm(vector<int> &A, int k) {
vector<int> ans;
for (int carry = 0, i = A.size() - 1; i >= 0 || k != 0 || carry != 0; --i, k /= 10) {