일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 스탭퍼
- 프로젝트
- 리얼 클래스
- 쓰릴오브파이트
- 미드시청
- 화상영어
- 3줄정리
- 읽기
- 파비최
- 사이드
- FIT XR
- 괜찮음
- 링피트
- realclass
- 30분
- 만화도
- English
- leetcode
- Problem Solving
- 매일
- 운동
- 영어원서읽기
- Writing
- 월간
- 영어공부
- 개발자
- 잡생각
- 뭐든
- 10분
- Daily Challenge
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.12.20 Today's Challenge 본문
https://leetcode.com/problems/image-smoother/
Image Smoother - LeetCode
Can you solve this real interview question? Image Smoother - An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nin
leetcode.com
class Solution:
def imageSmoother(self, img: List[List[int]]) -> List[List[int]]:
m, n = len(img), len(img[0])
s_img = [[0] * n for _ in range(m)]
for i in range(m):
for j in range(n):
s, cnt = 0, 0
for x in (i-1, i, i+1):
for y in (j-1, j, j+1):
if 0 <= x < m and 0 <= y < n:
s += img[x][y]
cnt += 1
s_img[i][j] = s // cnt
return s_img
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.12.22 Today's Challenge (0) | 2023.12.22 |
---|---|
2023.12.21 Today's Challenge (0) | 2023.12.21 |
2023.12.19 Today's Challenge (0) | 2023.12.19 |
2023.12.18 Today's Challenge (0) | 2023.12.18 |
2023.12.17 Today's Challenge (0) | 2023.12.17 |