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