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 | 31 | 
													Tags
													
											
												
												- Git
- 프로그래머스 파이썬
- 더현대서울 맛집
- leetcode
- 프로그래머스
- SW Expert Academy
- github
- AI 경진대회
- 백준
- gs25
- 파이썬
- programmers
- dacon
- hackerrank
- 캐치카페
- ubuntu
- 자연어처리
- 데이콘
- Docker
- 편스토랑
- Baekjoon
- 맥북
- PYTHON
- Real or Not? NLP with Disaster Tweets
- ChatGPT
- 우분투
- 편스토랑 우승상품
- 금융문자분석경진대회
- Kaggle
- 코로나19
													Archives
													
											
												
												- Today
- Total
솜씨좋은장씨
[Programmers] 한 번만 등장한 문자 (Python) 본문
728x90
    
    
  반응형
    
    
    
  
코딩 1일 1문제! 오늘의 문제는 프로그래머스의 한 번만 등장한 문자 입니다.
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
👨🏻💻 문제 풀이
단어가 얼마나 등장했는지 정보를 담은 freq_dict 을 만들고
freq_dict = {}
for word in list(s):
    if word not in freq_dict.keys():
        freq_dict[word] = 0
    freq_dict[word] += 1그 freq_dict 에서 한번씩만 등장한 단어만을 리스트에 남기고 오름차순으로 정렬한 다음
one_words = sorted([word[0] for word in freq_dict.items() if word[1] == 1])join 하여 정답을 만들면 끝!
"".join(one_words)👨🏻💻 코드 ( Solution )
def solution(s):
    freq_dict = {}
    
    for word in list(s):
        if word not in freq_dict.keys():
            freq_dict[word] = 0
        freq_dict[word] += 1
    one_words = sorted([word[0] for word in freq_dict.items() if word[1] == 1])
    
    return "".join(one_words)GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
| [Programmers] 바탕화면 정리 (Python) (0) | 2023.03.06 | 
|---|---|
| [Programmers] 가위 바위 보 (Python) (0) | 2023.03.05 | 
| [Programmers] 순서쌍의 개수 (Python) (0) | 2023.03.03 | 
| [Programmers] 숨어있는 숫자의 덧셈 (2) (Python) (0) | 2023.03.02 | 
| [Programmers] 다항식 더하기 (Python) (0) | 2023.03.01 | 
								  Comments
								
							
						
					
                    
                
					
					
					
					
					
					
				 
						
					 
					 
													 
													 
													