Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- Number Theory
- hash table
- database
- 구현
- geometry
- Class
- Stack
- Data Structure
- java
- dynamic programming
- Math
- greedy
- Counting
- bit manipulation
- 코테
- two pointers
- sorting
- simulation
- Tree
- array
- 자바
- 코딩테스트
- SQL
- string
- Method
- 파이썬
- Binary Search
- Matrix
- implement
- Binary Tree
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 171. Excel Sheet Column Number 본문
1. Input
1) 열 번호를 담고 있는 문자열 변수 columnTitle
2. Output
1) 문자열을 변환한 정수
2) A는 1, B는 2, ..., Z는 26, AA는 27, AB는 28, ...
3. Constraint
1) 1 <= columnTitle.length <= 7
2) columnTitle에 담긴 문자열은 영어 대문자 뿐이다.
3) columnTitle에 담긴 문자열의 범위는 ["A", "FXSHRXW"]이다.
4. Example
Input: columnTitle = "ZY"
Output: 701
설명:
- Z=26, Y=25이므로 26*26 + 25 = 676 + 25 = 701
5. Code
1) 첫 코드(2022/07/06)
int sum = 0;
for(int i=0 ; i<columnTitle.length() ; i++)
sum += (columnTitle.charAt(i)-64) * (int)Math.pow(26,columnTitle.length()-i-1);
return sum;
// 'A'=65이므로 64를 빼서 'A'를 1로 변환
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 191. Number of 1 Bits (0) | 2022.10.12 |
---|---|
[LeetCode/Easy] 190. Reverse Bits (0) | 2022.10.12 |
[LeetCode/Easy] 136. Single Number (0) | 2022.10.11 |
[LeetCode/Easy] 125. Valid Palindrome (0) | 2022.10.11 |
[LeetCode/Easy] 88. Merge Sorted Array (0) | 2022.08.24 |