[Java/C++] Easiest Possible Exaplained!!
How\'s going Ladies - n - Gentlemen, today we are going to solve another coolest problem i.e. Smallest String With A Given Numeric Value\n\nWhat the problem is 
How\'s going Ladies - n - Gentlemen, today we are going to solve another coolest problem i.e. **Smallest String With A Given Numeric Value**\n\nWhat the problem is saying, we have to generate the **string** with **numeric sum** equals to `k` & have the `n` characters\n\nLet\'s understand with an example,\n\n**Input**: n = 3, k = 27\n**Output**: "aay"\n\nAlright, so we can have upto 3 character\'s and their sum has to be equals to k.\n\nSo, what could be our `n = 3` character\'s is **`a a a`** why these because in the problem they have mentioned that they have to be in lexicographically order.\n\n![image](https://assets.leetcode.com/users/images/70cdd253-3b9f-402f-bbaa-13d202c107fe_1647908911.153984.png)\n\n```\nYou can do this same thing like in this way as well:-\na a a   = 3\n|\nb       = 4\n|\n|\n|\ny       = 27\n\nbut this is not a lexicographicall order!!\n```\n\nSo, i hope so now you have understaood why we start from the end of the string\n\n<hr>\n\nLet\'s look at our **`Approach`** take an example:-\n\n<hr>\n\n**Input**: n = 5, k = 73\n**Output**: "aaszz"\n\nSo, we have `n = 5` & our starting character\'s could be `a a a a a`.\n* First our job is subtract **5** from **k** which will comes out `73 - 5 = 68`\n* As you can see **68 is too big**, because the maximum we can form is by adding **z into it i.e. 25**\n* So, before doing that we will check whether **k is minimum or the 25**, which ever is minimum we\'ll add into the last character.\n* And **subtract the minimum from the k**\n* Forgot to mention that, we\'ll be having one array to store the result.\n\n```\nres [] = a a a a a\n\nres[--n] += min(25, k)   // get the last value min\nk -= min(25, k)         // and subtarct it from k as well\n\nSo, these are the 2 thing\'s we\'ll gonna follow until k > 0\n```\n\nLet\'s implement this into our example:-\n\n![image](https://assets.leetcode.com/users/images/a05843fc-ad11-4189-9fe0-a451d9ef8cd0_1647910249.0571206.png)\n\n*I hope so, ladies - n - gentlemen approach is absolute clear.* **Let\'s code it, up**\n\n**Java**\n```\nclass Solution {\n    public String getSmallestString(int n, int k) {\n        char res[] = new char[n];\n        Arrays.fill(res, \'a\');\n        k -= n;\n        \n        while(k > 0){\n            res[--n] += Math.min(25, k);\n            k -= Math.min(25, k);\n        }\n        return String.valueOf(res);\n    }\n}\n```\n\n**C++**\n```\nclass Solution {\npublic:\n    string getSmallestString(int n, int k) {\n        string res(n,\'a\');\n        k -= n;\n        \n        while(k > 0){\n            res[--n] += min(25, k);\n            k -= min(25, k);\n        }\n        return res;\n    }\n};\n```\nANALYSIS :-\n* **Time Complexity :-** BigO(N)\n\n* **Space Complexity :-** BigO(N)
[]