168. Excel Sheet Column Title ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7class Solution { public: string convertToTitle(int n) { return n == 0 ? "" : convertToTitle((n - 1) / 26) + (char)('A' + ((n - 1) % 26)); } }; 1 2 3 4 5class Solution { public String convertToTitle(int n) { return n == 0 ? "" : convertToTitle((n - 1) / 26) + (char) ('A' + ((n - 1) % 26)); } } 1 2 3 4 5class Solution: def convertToTitle(self, n: int) -> str: return (self.convertToTitle((n - 1) // 26) + chr(ord('A') + (n - 1) % 26) if n else '')