forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_1663.java
27 lines (26 loc) · 789 Bytes
/
_1663.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.fishercoder.solutions;
public class _1663 {
public static class Solution1 {
public String getSmallestString(int n, int k) {
StringBuilder sb = new StringBuilder();
int balance = k - n;
while (balance > 0) {
if (balance > 25) {
balance -= 25;
sb.append("z");
n--;
} else {
char str = (char) ('a' + balance);
sb.append(str);
n--;
while (n > 0) {
sb.append("a");
n--;
}
break;
}
}
return sb.reverse().toString();
}
}
}