Plus One Algorithm

However, both OnePlus and Oppo denies OnePlus is a subsidiary and keep they are independent company, although OnePlus confirmed it uses Oppo's manufacturing line and shares part of the supply chain resources with Oppo. One plus technology (Shenzhen) Co., Ltd., normally referred to as OnePlus, is a Chinese smartphone manufacturer based in Shenzhen, Guangdong. In June 2016, OnePlus decided to pull out of the Indonesian market due to local regulations for imported 4 G smartphones restricting sales of the OnePlus 2.At the launch event of the OnePlus 6 on 17 May 2018, OnePlus announced it would be opening five new OnePlus Experience shops in India, as well as 10 new service centers. On 16 December 2014, The Supreme Court of India and Delhi High Court banned the import and sale of OnePlus One telephones following a lawsuit by Micromax alleging it has exclusivity for shipping telephones with Cyanogen OS software in India. Lau denied that OnePlus was a wholly owned subsidiary of Oppo and stated that Oppo electronics and not Oppo Mobile (the telephone manufacturer) is a major investor of OnePlus and that they are" in talks with other investors.
class Solution {
public:
    vector<int> plusOne(vector<int>& digits) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        
        int carry = 0;
        int size = digits.size();
        digits[size-1] += 1;
        
        for (int i = size - 1; i >= 0; i--) {
            int val = digits[i];
            digits[i] = (val + carry) % 10;
            carry = (val + carry) / 10;
            if (carry == 0) break;
        }
        if (carry) {
            digits.insert(digits.begin(), carry);
        }
        return digits;
    }
};

LANGUAGE:

DARK MODE: