[C++] Greedy Approach
Approach 1: Greedy Solution\nIdea:\nGenerate the initial string with all \'a\' characters. This will reduce k by n.\nThen, turn rightmost \'a\' into \'z\' (\'a\
Approach 1: Greedy Solution\nIdea:\nGenerate the initial string with all \'a\' characters. This will reduce k by n.\nThen, turn rightmost \'a\' into \'z\' (\'a\' + 25, or \'a\' + k) while k is positive.\n```\nclass Solution {\npublic:\n    string getSmallestString(int n, int k) {\n        string ans(n, \'a\');\n        k -= n;\n        while(k>0){\n            ans[--n] += min(25, k);\n            k -= min(25, k);\n        }\n        return ans;\n    }\n};\n```\n\nReference:\n[1] https://leetcode.com/problems/smallest-string-with-a-given-numeric-value/discuss/944538/C%2B%2B-Reverse-Fill
[]