Java Backtracking O(n) Easy
Intutition\n- Backtracking - Keep decreasing the value of start so that the sum always remains equal to target k and length always remains n.\n\n\n# Approach\n 
# Intutition\n- Backtracking - Keep decreasing the value of start so that the sum always remains equal to target k and length always remains n.\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Set start value to z and buf value to n.\n- Start is used to store the character to be appended and buf is\n  used to keep reference of the length required.\n- Initialize array to store resultant string.\n- If k is less than index value of start + buffer value\n    then decrement start till condition is satisfied\n- Add start value to resultant array ch[].\n  \n\n# Complexity\n- Time complexity: O(n)\n- Space complexity: O(1)\n\n\n\n# Code\n```\nclass Solution {\n    public String getSmallestString(int n, int k) \n    {\n        char start=\'z\';\n\n        String ans="";\n\n        int buf=n;\n        int c=n-1;\n\n        char ch[] = new char[n];\n\n        while(k>0)\n        {\n            // System.out.print(start);\n            if(k<(start-96)+buf)\n            {\n                \n                while(k!=(start-96)+buf-1)\n                {\n                    start--;\n                }\n                // System.out.print(start);\n            }\n            // System.out.println(start);\n           ch[c--]=start;\n            k-=(start-96);\n            buf--;\n            \n        }\n\n        ans= new String(ch);\n        return ans;\n    }\n}\n```
['Java']