package leetcode;

/**
 * https://leetcode.com/problems/smallest-string-with-a-given-numeric-value/
 */
public class Problem1663 {
    public String getSmallestString(int n, int k) {
        char[] chars = new char[n];
        for (int i = chars.length - 1; i >= 0; i--) {
            // TODO
        }
        return new String(chars);
    }

    public static void main(String[] args) {
        Problem1663 prob = new Problem1663();
        System.out.println(prob.getSmallestString(3, 27)); // "aay"
        System.out.println(prob.getSmallestString(5, 73)); // "aaszz"
        System.out.println(prob.getSmallestString(4, 47)); // "aasz"
        System.out.println(prob.getSmallestString(27, 43)); // "aaaaaaaaaaaaaaaaaaaaaaaaaaq"
        System.out.println(prob.getSmallestString(28, 43)); // "aaaaaaaaaaaaaaaaaaaaaaaaaaap"
        System.out.println(prob.getSmallestString(28, 143)); // "aaaaaaaaaaaaaaaaaaaaaaapzzzz"
        System.out.println(prob.getSmallestString(28, 53)); // "aaaaaaaaaaaaaaaaaaaaaaaaaaaz"
    }
}

@@ -212,16 +212,43 @@
 har%5Bn%5D;%0A
+        int remaining = k;%0A
         
@@ -309,740 +309,331 @@
     
-// TODO%0A        %7D%0A        return new String(chars);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1663 prob = new Problem1663();%0A        System.out.println(prob.getSmallestString(3, 27)); // %22aay%22%0A        System.out.println(prob.getSmallestString(5, 73)); // %22aaszz%22%0A        System.out.println(prob.getSmallestString(4, 47)); // %22aasz%22%0A        System.out.println(prob.getSmallestString(27, 43)); // %22aaaaaaaaaaaaaaaaaaaaaaaaaaq%22%0A        System.out.println(prob.getSmallestString(28, 43)); // %22aaaaaaaaaaaaaaaaaaaaaaaaaaap%22%0A
+int x = remaining - 26 - i;%0A            if (x %3C 0) %7B%0A                x = remaining - i;%0A                chars%5Bi%5D = (char) (x + 'a' - 1);%0A                remaining -= x;%0A            %7D else %7B%0A                chars%5Bi%5D = 'z';%0A                remaining -= 'z' - 'a' + 1;%0A         
    
+%7D%0A
      
-System.out.println(prob.getSmallestString(28, 143)); // %22aaaaaaaaaaaaaaaaaaaaaaapzzzz%22%0A        System.out.println(prob.getSmallestString(28, 53)); // %22aaaaaaaaaaaaaaaaaaaaaaaaaaaz%22
+   %7D%0A        return new String(chars);
 %0A   

Solve problem 1663