Java, O(n), Greedy try smallest character from left to right
\nclass Solution {\n    public String getSmallestString(int n, int k) {\n        StringBuilder res = new StringBuilder();\n        for(int i = 0; i < n; i++){\n
```\nclass Solution {\n    public String getSmallestString(int n, int k) {\n        StringBuilder res = new StringBuilder();\n        for(int i = 0; i < n; i++){\n            int left = n - i - 1;\n            //check if we put a \'a\' here, it\'s still possible to satisfy the requirement\n            if(k <= left * 26){\n                res.append("a");\n                k -= 1;\n            }\n            else{\n                int cur = k - left * 26;\n                res.append((char)(\'a\' - 1 + cur));\n                k -= cur;\n            }\n        }\n        return res.toString();\n    }\n}\n```
[]