标签:style color io os ar for on amp ad
Given a non-negative number represented as an array of digits, plus one to the number.
The digits are stored such that the most significant digit is at the head of the list.
class Solution { public: std::vector<int> plusOne(std::vector<int> &digits) { std::vector<int> result; int t = 1; for(int i = digits.size() - 1; i >= 0; i--) { t += digits[i]; result.insert(result.begin(),t % 10); t /= 10; } if(t > 0) { result.insert(result.begin(),t); } return result; } };
标签:style color io os ar for on amp ad
原文地址:http://blog.csdn.net/akibatakuya/article/details/40075399