Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 코로나19
- 백준
- 우분투
- AI 경진대회
- Docker
- leetcode
- 더현대서울 맛집
- gs25
- 편스토랑 우승상품
- ubuntu
- Git
- ChatGPT
- dacon
- Real or Not? NLP with Disaster Tweets
- 캐치카페
- Kaggle
- hackerrank
- SW Expert Academy
- 파이썬
- 편스토랑
- 데이콘
- 자연어처리
- 프로그래머스 파이썬
- Baekjoon
- 금융문자분석경진대회
- 맥북
- PYTHON
- programmers
- github
- 프로그래머스
Archives
- Today
- Total
솜씨좋은장씨
[BaeKJoon] 11656번: 접미사 배열 (Python) 본문
728x90
반응형

1일 1문제 25일차!
오늘의 문제는 백준의 접미사 배열입니다.
오늘은 이전에 풀었던 문제를 다시 풀어보았습니다.
11656번: 접미사 배열
첫째 줄에 문자열 S가 주어진다. S는 알파벳 소문자로만 이루어져 있고, 길이는 1,000보다 작거나 같다.
www.acmicpc.net
이전 제출 코드
string = input()
string = list(string)
myStrings = []
while len(string) > 0:
myStrings.append(str(string))
string.pop(0)
myStrings = set(myStrings)
new = []
for word in myStrings:
word = word.replace('[', '')
word = word.replace(',', '')
word = word.replace(']', '')
word = word.replace(' ', '')
word = word.replace("'", '')
new.append(word)
result = sorted(new)
for word in result:
print(word)
수정한 코드
string = input()
string = list(string)
myStrings = []
while len(string) > 0:
myStrings.append(''.join(string))
string.pop(0)
result = sorted(myStrings)
for word in result:
print(word)

이전보다 속도도 빠르고 메모리도 적게쓰는 코드로 변경해보았습니다.
오늘은 이만 아르바이트를 하러!
SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 21. Merge Two Sorted Lists (Python) (0) | 2020.03.04 |
---|---|
[leetCode] 151. Reverse Words in a String (Python) (0) | 2020.03.03 |
[Programmers] 스택/큐 : 프린터 (Python) (0) | 2020.03.01 |
[leetCode] 7. Median of Two Sorted Arrays (Python) (2) | 2020.02.29 |
[Programmers] 완전탐색 : 소수 찾기 (Python) (0) | 2020.02.28 |