Accepted 4ms c++ solution, easy and short.
class Solution {\n    public:\n        std::vector<int> plusOne(std::vector<int>& digits) {\n            int pos = digits.size() - 1;\n            while (pos >=
    class Solution {\n    public:\n        std::vector<int> plusOne(std::vector<int>& digits) {\n            int pos = digits.size() - 1;\n            while (pos >= 0 && digits[pos] == 9) {\n                digits[pos] = 0;\n                --pos;\n            }\n            if (pos == -1) {\n                digits[0] = 1;\n                digits.push_back(0);\n            } else {\n                ++digits[pos];\n            }\n            return digits;\n        }\n    };
[]