Skip to content

Commit

Permalink
Create 28.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
pin3da authored Jan 28, 2021
1 parent ee47738 commit abf304d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions solved/LeetCode/Challenges/2020/January/28.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
fun getSmallestString(n: Int, k: Int): String {
val ans = IntArray(n) {1}
var extra = k - n;
for (i in ans.indices.reversed()) {
val take = Math.min(extra, 25)
ans[i] += take
extra -= take
}
return ans.map {it -> (96 + it).toChar()}.joinToString(separator="")
}
}

0 comments on commit abf304d

Please sign in to comment.