Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

숫자 변환하기 #147

Merged
merged 1 commit into from
Apr 12, 2023
Merged

숫자 변환하기 #147

merged 1 commit into from
Apr 12, 2023

Conversation

NamJwong
Copy link
Member

문제

https://school.programmers.co.kr/learn/courses/30/lessons/154538

풀이 후기

BFS로 풀다가 실패해서 풀이를 찾아봤다.

내가 BFS의 개념 중 잊고 있던 것이 있어 실패했었다 ..

BFS는 최단 거리 찾기 문제에 종종 쓰인다.
한 뎁스씩 가능한 모든 루트를 검사한 뒤 다음 뎁스로 넘어가기 때문에 가장 먼저 발견한 노드가 최단 거리이기 때문이다.
그렇기 때문에 이 문제에서 BFS를 쓸 수 있었던 것인데,
내가 그 사실을 간과한 채 visited를 제대로 활용하지 못했다.

모든 이미 방문한 숫자는 당시의 카운트가 최솟값인 것이며, y 또한 그렇다.

@NamJwong NamJwong self-assigned this Apr 12, 2023
@NamJwong NamJwong merged commit 6ab5c0f into main Apr 12, 2023
@NamJwong NamJwong deleted the algorithm/#147 branch April 12, 2023 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant