Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
문제
https://school.programmers.co.kr/learn/courses/30/lessons/12905
풀이 후기
BFS 비슷하게 풀었다가 케이스도 몇 개 틀리고, 아예 시간 초과가 나서 도대체 어떻게 풀지? 하고 풀이를 찾아봤더니 DP 문제였다.
이런 구상은 어떻게 하는 거지 .. ㅠ 문제를 많이 풀어야겠다.
생각해보니 BFS는 최대 N^2지만, 내가 작성한 BFS 비스무리한 코드는 N^2가 넘어간다..! N이 1,000이니 시간 초과는 당연했다ㅠ
다른 사람의 풀이와 비교
좋아요 2등 풀이
이렇게 for문을 통해 인덱스 1부터 탐색하게 해서 내 코드의
board[x - 1] && board[x - 1][y - 1]조건 검사를 안 하게 해주는 것도 방법이다.