| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 사이드
- Writing
- 파비최
- 쓰릴오브파이트
- realclass
- 영어공부
- 30분
- 잡생각
- 스탭퍼
- leetcode
- 괜찮음
- 만화도
- 운동
- Problem Solving
- English
- 미드시청
- 읽기
- 영어원서읽기
- 링피트
- 프로젝트
- FIT XR
- 3줄정리
- Daily Challenge
- 개발자
- 월간
- 매일
- 10분
- 리얼 클래스
- 뭐든
- 화상영어
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 |
Comments