用的C++
class Solution { public: vector<int> plusOne(vector<int>& digits) { const int n = digits.size(); vector<int> result; long int num=0; for(int i = 0;i < n;i++){ num += digits[i]*pow(10,n-i-1); } num++; while(num > 0){ int i = num % 10; num /= 10; result.push_back(i); } reverse(result.begin(),result.end()); return result; } };
输入: [6,1,4,5,3,9,0,1,9,5,1,8,6,7,0,5,5,4,3]
输出: [6,1,4,5,3,9,0,1,9,5,1,8,6,7,0,5,4,0,9]
预期: [6,1,4,5,3,9,0,1,9,5,1,8,6,7,0,5,5,4,4]
不一样,通过109个例子中的79个
守候你守候我
相关分类