标签:style blog io color ar os sp div on
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: vector<int> plusOne(vector<int> &digits) { vector<int>::reverse_iterator r_iter=digits.rbegin(); while(*r_iter==9){ *r_iter=0; r_iter++; if(r_iter==digits.rend()){ digits.insert(digits.begin(),1); return digits; } } (*r_iter)++; return digits; } };
标签:style blog io color ar os sp div on
原文地址:http://www.cnblogs.com/li303491/p/4078828.html