By Math
This is simply a math problem.\n\n1. Fill all with "a".\n2. Then for each extra number, add from the right. The number of "z"\'s on the right can be calculated 
This is simply a math problem.\n\n1. Fill all with "a".\n2. Then for each extra number, add from the right. The number of "z"\'s on the right can be calculated as `extra/25`.\n3. The letter right after "a"\'s can also be calculated by `\'a\' + extra%25`\n4. Then just add "a"\'s, first non-\'a\' and fill rest with "z".\n\nA corner case to handle is when all  are "z"\'s. \n\n\n```\nclass Solution {\n    public String getSmallestString(int n, int k) {\n        // fill all with 1, then fill from the back\n        int extra = k - n;\n        int zs = extra/25;\n        int lastletter = extra%25;\n        \n        StringBuilder sb = new StringBuilder();\n        for (int i = 1 ; i < n - zs ; i++) {\n            sb.append("a");\n        }\n        if (n > zs) {\n            sb.append((char)(\'a\' + lastletter));\n        }\n        for (int i = 0 ; i < zs ; i++) {\n            sb.append("z");\n        }\n        \n        return sb.toString();\n    }\n}\n```
['Math', 'Java']