Problem Solving/리트코드(leetcode)
[Leetcode/C++] 168. Excel Sheet Column Title
높은곳에영광
2022. 1. 24. 02:22
class Solution {
public:
string convertToTitle(int n) {
string answer = "";
while(n != 0) {
answer = (char)((n - 1) % 26 + 'A') + answer;
n = (n-1) / 26;
}
return answer;
}
};
그냥 단순한 사칙연산과 구현문제였는데 26으로 나누고 마드하는 전형적인 문제이다.
문제: https://leetcode.com/problems/excel-sheet-column-title/
Excel Sheet Column Title - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com