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
- 알고리즘
- 자바
- Java
- 멱등성
- effective java
- 클린아키텍처
- 동시성처리
- 이펙티브자바
- thymeleaf
- EffectiveJava
- EntityGraph
- lombok
- Spring Security
- JPA
- 캐시
- 타임리프
- 배낭문제
- Garbage Collection
- collapse
- TDD
- interceptor
- Transactional
- 코딩테스트
- cache
- JVM
- AOP
- @Transactional
- 파이썬
- BFS
- spring
Archives
- Today
- Total
목록BFS (1)
Jinnie devlog
BFS(너비 우선 탐색) - 백준 1697, 5014
1697(숨바꼭질), 5014(스타트링크) 두 문제 모두 큐를 활용한 BFS 방식의 문제다. 이동할 수 있는 거리만큼의 for문을 돌며, 큐에 삽입하고 이동거리를 +1씩 해주며 최종 목적지의 이동거리를 구하였다. 똑같은 위치를 반복해서 방문하게 되면, 필요없는 작업을 하게되어 visited 배열을 통해 한번만 방문하도록 하였다. 백준 1697 숨바꼭질 from collections import deque def bfs(s): q = deque([s]) visited[s]=1 while q: cur = q.popleft() if cur == K: return count[K] for i in (cur-1, cur+1, cur*2): if 0
Algorithm
2023. 1. 25. 10:07