diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/excel_sheet_column_title.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/excel_sheet_column_title.cpp')
-rw-r--r-- | other/excel_sheet_column_title.cpp | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/other/excel_sheet_column_title.cpp b/other/excel_sheet_column_title.cpp deleted file mode 100644 index 3de395f..0000000 --- a/other/excel_sheet_column_title.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// 168. Excel Sheet Column Title -#include "leetcode.h" - -/* - * given an integer 'column_number', return its corresponding column title as it - * appears in an excel sheet. for example: A -> 1 B -> 2 C -> 3 - * ... - * Z -> 26 - * AA -> 27 - * AB -> 28 - * ... - */ - -class Solution { -public: - string convertToTitle(int n) { - if (n < 27) - return string(1, 'A' + (n - 1) % 26); - string ans = ""; - while (n > 0) { - if (!(n % 26)) { - ans += 'A' + 25; - n--; - } else { - ans += 'A' + n % 26 - 1; - } - n /= 26; - } - reverse(ans.begin(), ans.end()); - return ans; - } -}; - -int main() { - Solution obj; - cout << obj.convertToTitle(1) << endl; // expect: A - cout << obj.convertToTitle(28) << endl; // expect: AB - cout << obj.convertToTitle(701) << endl; // expect: ZY -} |