Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 574 Bytes

Question_168.md

File metadata and controls

22 lines (18 loc) · 574 Bytes

LeetCode Records - Question 168 Excel Sheet Column Title

Attempt 1:

class Solution {
    public String convertToTitle(int columnNumber) {
        StringBuilder stringBuilder = new StringBuilder();

        while (columnNumber > 0) {
            int offset = (columnNumber - 1) % 26;
            stringBuilder.append((char)(offset + 'A'));
            columnNumber = (columnNumber - 1) / 26;
        }

        return stringBuilder.reverse().toString();
    }
}
  • Runtime: 0 ms (Beats: 100.00%)
  • Memory: 40.48 MB (Beats: 79.54%)