코딩테스트(2)
-
2. Tries 알고리즘
Trie 알고리즘 - 빠른 문자열 검색 자료구조 - Tree 형태로 각 단어를 저장. words = ["frodo", "front", "frost", "frozen", "frame", "kakao"] head, head_rev = {},{} lengths = [] def tries(head, word): node = head # 포인터 지정 for w in word: if w not in node: node[w]={} node = node[w] # 포인터 이동 if 'len' not in node: node['len'] = [len(word)] else: node['len'].append(len(word)) node['end']=True # 각 단어의 끝을 표시 for word in words: trie..
2024.04.19 -
1. BFS / DFS
코딩테스트 첫단계. BFS / DFS부터 정복하자. - BFS : q - DFS : stack **암기 이때 DFS는 백트래킹이라고도 불리며 보통 재귀함수로 구현한다. 1. 종료조건 맨위 2. 방문처리 3. 재귀함수 호출 4. 방문취소 예제문제 https://school.programmers.co.kr/learn/courses/30/parts/12421 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr https://www.acmicpc.net/step/34 백트래킹 단계 조금 더 복잡한 백트래킹 문제 1 www.acmicpc.net 백준 18352 1450..
2024.04.19