https://www.acmicpc.net/problem/7120
1
2
3
4
5
6
7
8
9
10
|
def sol(s):
answer = ''
for i in range(1,len(s)):
if s[i-1]!=s[i]:
answer +=s[i-1]
return answer+s[-1]
if __name__ == '__main__':
s = input()
print(sol(s))
|
cs |
반복문을 통해서 동일하지 않은 문자열을 찾고, 가장 마지막 문자는 반복문을 통해 해결이 안돼니 따로 추가
Search for non-dentical strings through a loop statement, and add the last character separately because it cannot be resolved through a loop statement.
반응형
'python-algorithm' 카테고리의 다른 글
백준 26041 비슷한 전화번호 표시 (0) | 2022.12.06 |
---|---|
백준 6500 랜덤 숫자 만들기 (0) | 2022.12.06 |
백준 6438 Reverse Text (1) | 2022.12.05 |
백준 13234 George Boole (0) | 2022.12.05 |
백준 15080 Every Second Counts (0) | 2022.12.04 |
댓글