Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-04-26_18-06-58.png
46 KB
#N989. Add to Array-Form of Integer
problem link
#solution
class Solution {
public List<Integer> addToArrayForm(int[] num, int k) {
List<Integer> list = new ArrayList<>();
int qarz=0, temp=0;
for(int i=num.length-1; i>=0; i--){
temp=num[i]+k%10+qarz;
k/=10;
System.out.println(temp);
list.add(0, temp%10);
qarz=temp/10;
}
k+=qarz;
while(k!=0){
list.add(0, k%10);
k/=10;
}
return list;
}
}