일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Python
- t1
- 운영체제
- Class
- concurrency
- 컴퓨터의 구조
- 밴픽
- Protocol
- LeetCode
- 315. Count of Smaller Numbers After Self
- Regular Expression
- 30. Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- kaggle
- iterator
- Convert Sorted List to Binary Search Tree
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- data science
- 43. Multiply Strings
- 프로그래머스
- 715. Range Module
- 파이썬
- Python Implementation
- Python Code
- 시바견
- attribute
- Generator
- DWG
- shiba
Archives
- Today
- Total
Scribbling
LeetCode: 6. ZigZag Conversion 본문
class Solution:
def convert(self, s: str, numRows: int) -> str:
if numRows == 1:
return s
board = [[] for _ in range(numRows)]
denom = 2 * numRows - 2
for i, char in enumerate(s):
remainder = i % denom
if remainder < numRows:
board[remainder].append(char)
else:
board[2 * numRows - remainder - 2].append(char)
ret = ''
for i in range(len(board)):
for j in board[i]:
ret += j
return ret
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 11. Container With Most Water (1) | 2021.08.17 |
---|---|
LeetCode: 8. String to Integer (atoi) (0) | 2021.08.16 |
LeetCode: 207. Course Schedule (0) | 2021.08.14 |
LeetCode: 1584. Min Cost to Connect All Points (0) | 2021.08.13 |
LeetCode: 5. Longest Palindromic Substring (0) | 2021.08.12 |