Skip to content

Commit

Permalink
Create 0168-excel-sheet-column-title.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
a93a authored Aug 22, 2023
1 parent 114b7c5 commit 20a62bf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kotlin/0168-excel-sheet-column-title.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution {
fun convertToTitle(_cN: Int) = buildString {
var cN = _cN
while (cN > 0) {
val rem = (cN - 1) % 26
val char = 'A' + rem
insert(0, char)
cN = (cN - 1) / 26
}
}
}

0 comments on commit 20a62bf

Please sign in to comment.