[C++] Simple O(N) with explanation
The idea is simple:\n1) Build the string of length k, which consists of letter \'a\' (lexicographically smallest string).\n2) Increment string from right to lef
The idea is simple:\n1) Build the string of length k, which consists of letter \'a\' (lexicographically smallest string).\n2) Increment string from right to left until it\'s value won\'t reach the target.\n\nTime complexity O(n), space complexity O(1) - no additional space used except for result string.\n```\nclass Solution {\npublic:\n    string getSmallestString(int n, int k) {\n        string res(n, \'a\');\n        k -= n;\n        \n        int i = res.size() - 1;\n        while (k > 0) {\n            int tmp = min(k, 25);\n            res[i] += tmp;\n            k -= tmp;\n            --i;\n        }\n        \n        return res;\n    }\n};
['C', 'C++']