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
- 알고리즘
- 비트마스크알고리즘
- 스타트와링크
- Rtl
- verilog HDL
- 가속기시스템
- verilog
- 감시
- 비트마스크
- 가속컴퓨팅
- HDL
- RTLEngineer
- 비트마스킹
- 모델링
- testbench
- boj
- HWEngineer
- 코딩테스트
- DFS
- 모듈
- 최적화
- 14889
- verilogHDL
- 백준
- HW
- 15683
- dfs연습문제
- Module
Archives
- Today
- Total
oohyoo 님의 블로그
[Python] 프로그래머스 - 외톨이 알파벳 본문
[문제]
[풀이]
def solution(input_string):
count_dict = {}
prev = None
for ch in input_string:
if ch != prev:
count_dict[ch] = count_dict.get(ch, 0) + 1
prev = ch
print(count_dict)
lonely_chars = sorted([ch for ch, count in count_dict.items() if count >= 2])
return "".join(lonely_chars) if lonely_chars else "N"
.get() 메서드를 살펴보면, ch의 값이 없다면 0을 반환하겠다는 의미로 사용되었다.
반응형
'코딩테스트' 카테고리의 다른 글
[Python] 프로그래머스 - 미로 탐험2 (0) | 2025.02.03 |
---|---|
[Python] 프로그래머스 - 가장 빠른 거리 (0) | 2025.02.03 |
[Python] 프로그래머스 Sort 교육자료 (0) | 2025.02.03 |
[Python] 프로그래머스 Set 강의자료 (0) | 2025.02.03 |
[Python] 프로그래머스 Heap 강의자료 (0) | 2025.02.03 |