Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
class Solution {
public:
vector<int> addToArrayForm(vector<int>& A, int K) {
int i=A.size()-1;
vector<int> result={};
long long int no=0;
for(int x:A)
{
no=no+x*pow(10,i);
i--;
}
no=no+K;
if(no==0)
return {0};
while(no>0)
{
long long int r=no%10;
result.push_back(r);
no=no/10;
}
reverse(result.begin(),result.end());
return result;
}
};
I am getting this error with long long.
Line 9: Char 14: runtime error: 1e+19 is outside the range of representable values of type 'long long' (solution.cpp) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior prog_joined.cpp:18:14