[PGS] 이웃한 칸 - #81
Open
been12151 wants to merge 18 commits into
Open
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.
🍪 문제 이름
Resolve: 이웃한 칸
🍊 문제 정의
inputboard: 문자열로 이루어진 N×N 크기의 2차원 배열h: 기준 칸의 행 인덱스w: 기준 칸의 열 인덱스outputboard[h][w]와 상하좌우로 이웃한 칸 중 같은 문자를 가진 칸의 수예시
🍑 알고리즘 설계
상하좌우 방향을
dx,dy배열로 정의하고 4방향을 순회.각 방향의 좌표가 보드 범위 내에 있고, 해당 칸의 문자가 기준 칸과 같으면
count증가.🥝 최악 수행 시간 복잡도
O(1)🍰 특이 사항 (Optional)
없음