문제
https://school.programmers.co.kr/learn/courses/30/lessons/250125
코드
def solution(board, h, w):
n=len(board)
count=0
dh=[0, 1, -1, 0]
dw=[1, 0, 0, -1]
for i in range(0,4):
h_check=h + dh[i]
w_check=w + dw[i]
if(h_check >=0 and h_check<n and w_check >=0 and w_check<n ):
if(board[h][w] == board[h_check][w_check]) :
count=count+1
answer = count
return answer
728x90
'study > 알고리즘' 카테고리의 다른 글
[알고리즘] 그리디 알고리즘이란? (0) | 2024.04.08 |
---|---|
[파이썬] 파이썬 문법 정리 (1) | 2024.04.01 |
[코드업] 코드업 파이썬 기초 100제 (0) | 2024.04.01 |
[프로그래머스] 코딩테스트 연습 <가장 가까운 같은 글자> (python) (0) | 2024.02.25 |
[프로그래머스 코딩테스트 입문 100문제] Day 2 사칙연산, 조건문, 배열 (Python) (0) | 2024.02.24 |