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
- 프로그래머스게임맵최단거리
- pytorch
- 프로그래머스파이썬
- Paper list
- ssd
- Pytorch pruning
- Two stage Detector
- 프로그래머스네트워크
- 커피후기
- Object Detection
- 최솟값 만들기
- 프로그래머스타겟넘버
- One stage detector
- 다음큰숫자
- 코딩테스트네트워크
- ECCV
- 타겟넘버bfs
- 프로그래머스
- 코딩테스트2단계
- 프로그래머스bfs
- 프로그래머스타겟넘버정답
- 프로그래머스너비우선탐색
- Single Shot MultiBox Detector
- Code Study
- deep learning
- 프로그래머스타겟넘버파이썬
- 코딩테스트연습
- SSD 리뷰
- Pruning Tutorial
- Faster R-CNN
Archives
- Today
- Total
soyeonland
단어변환 본문
1) 실수
Case3에서만 실패가 떴었다.
기존에 짰던 logic은 set을 이용했는데,
set을 이용하면 hta 에서 has 도 변경 가능하게 된다.
이렇게 되면 문제 조건을 위배하게 된다
2) 이중 포문이여도 괜찮은 이유
단어의 길이가 최대 10 이고 단어 리스트가 최대 50 개이다
10*50 = 500 이기 때문에 문제 없다고 판단했다
from collections import deque
#case1: 변환할 수도 있음
#case2: 변환할 수 없을수도 있음
deq = deque()
def search(begin, target, words):
deq.append([begin,0])
while(len(deq)>=1):
cur_word, cur_count = deq.popleft()
#print('cur word', cur_word)
for word in words:
count = 0
for i in range(len(word)):
if word[i] == cur_word[i]:
count +=1
if count == len(word)-1:
#if len(set(word)-set(cur_word))==1:
# print('word',word)
#print('target',target)
if word == target:
return cur_count + 1
deq.append([word, cur_count+1])
#print(deq)
return 0
def solution(begin, target, words):
answer = 0
if target in words:
answer = search(begin, target, words)
else:
return 0
return answer
'Study > 코딩테스트 연습' 카테고리의 다른 글
프로그래머스 dfs/bfs 네트워크 파이썬 (0) | 2024.10.13 |
---|---|
프로그래머스 dfs/bfs 타겟넘버 python (0) | 2024.10.09 |
귤고르기 (0) | 2024.07.30 |
N개의 최소 공배수 (0) | 2024.07.17 |
점프와 순간이동 (0) | 2024.07.17 |