Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- fun convertToTitle(columnNumber: Int): String {
- val aCode = 64
- val dimentionNumber = 26
- val result = StringBuilder()
- var num = columnNumber
- while (num > 0) {
- val remainder = if (num % dimentionNumber == 0) dimentionNumber
- else num % dimentionNumber
- val ch = (remainder + aCode).toChar()
- result.insert(0, ch)
- num -= remainder
- num /= dimentionNumber
- }
- return result.toString()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement