c++ | Easy approach | Greedy | with explanation | with example
Input: n = 5, k = 73\nOutput: "aaszz"\n\nstep 1: make string of length n=5 and fill it with \'a\'. after step 1 our ans string will look like ans="aaaaa"\nstep 
Input: n = 5, k = 73\nOutput: "aaszz"\n\nstep 1: make string of length n=5 and fill it with \'a\'. after step 1 our **ans** string will look like **ans="aaaaa"**\nstep 2: iterate from back and keep the track of **sumOfString** after replacing ith index with \'z\'. sumOfString(aaaaz) is 1+1+1+1+26=30.\nstep 3: if sumOfString less than k then will update our \'ans\' string, repeat this untill we find sumOfString greater than k. \n\nsumOfString(aazzz) is 1+1+26+26+26=80, (80>k) so we can\'t add \'z\' at 2nd index. we need to find something smaller than \'z\'. till here \'ans\' string is aaazz and its sum is 55\n\nstep 4: replace ans[i] with char at \n(k-sumOfString+1) => ( 73-55+1)=19 (\'s\') \n**ans=aaszz**\n \n\n\n\n\n\n\n\n```\nclass Solution {\npublic:\n    string getSmallestString(int n, int k) {\n\t\t//creating string of length n while initializing with minimum lexicographical order\n        string ans(n,\'a\');\n        int stringSum=n;\n        \n        \n        for(int i=n-1;i>=0;i--){\n\t\t\t//calculating sum of string after appending \'z\' at ith index\n\t\t\t// if (k-sumOfString) >=0 then we\'ll add \'z\' at ith index\n            if(k-(i+(n-i)*(\'z\'-\'a\'+1))>=0){\n                ans[i]=\'z\';\n                stringSum=(i+(n-i)*(\'z\'-\'a\'+1));\n            }else{\n\t\t\t\t//else add char smaller than \'z\' \n                ans[i]=\'a\'+(k-stringSum);\n                break;\n            }\n        }\n        return ans;\n    }\n};\n```
['Greedy', 'C']