C++ Easy Code || Fully Explained in Simple Steps || Clean and Clear code + Explanation
\nThe most clear explanation of the algorithm is as:\n\nStep - 1 Initialize  a string s with n number of \'a\' to make it as a smallest possible lexiographic.\n
\n**The most clear explanation of the algorithm is as:**\n\n*Step - 1 Initialize  a string s with n number of \'a\' to make it as a smallest possible lexiographic.\nStep - 2 Count of \'a = 1\' , so if i have n number of \'a\' it means it sum is also \'n\'.\nStep - 3 Reduce the value of k by n (i.e k=k-n);\nStep - 4 Start traversing the string from the end because if we append any character from starting then there is chances of not getting smallest possible lexiographic order. \n\t\t Ex if we have to append \'z\' then from starting it would be like zaaa and from end it would be like aaaz which clearly shows that aaaz<zaaa.\nStep - 5 If \'k\' becomes \'0\' stop the traversal because that would be our answer.\nStep - 6 Else if k < 25, it means for getting the sum just replace i th character by \'a\'+k. And update k by k=0.\nStep - 7 Else k=> 25 so iterate more and replace i th character by (\'a\'+25) and move ahead. And update k by k-25*\n\n```\nclass Solution {\npublic:\n    string getSmallestString(int n, int k) {\n        string ans;\n        ans.insert(ans.begin(),n, \'a\');\n        k-=n;\n        \n        for(int i = n-1; i>=0; i--){\n            if(k>=25){\n                ans[i]+=25;\n                k-=25;\n            }\n            \n            else{\n                ans[i]+=k;\n                k = 0;\n            }\n            \n            if(k == 0){\n                break;\n            }\n        }\n        \n        return ans;\n    }\n};\n```
['String', 'Greedy', 'C', 'C++']