일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 매일
- 잡생각
- Writing
- 뭐든
- 운동
- 쓰릴오브파이트
- 괜찮음
- 사이드
- 영어공부
- 스탭퍼
- 파비최
- 미드시청
- leetcode
- 월간
- 30분
- 10분
- realclass
- 읽기
- 3줄정리
- English
- 프로젝트
- Problem Solving
- 만화도
- 영어원서읽기
- 리얼 클래스
- FIT XR
- 링피트
- 개발자
- Daily Challenge
- 화상영어
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.12.16 Today's Challenge 본문
Difference Between Ones and Zeros in Row and Column - LeetCode
Can you solve this real interview question? Difference Between Ones and Zeros in Row and Column - You are given a 0-indexed m x n binary matrix grid. A 0-indexed m x n difference matrix diff is created with the following procedure: * Let the number of ones
leetcode.com
문제가 이해가 잘 안되서 일단 패스..!
class Solution:
def onesMinusZeros(self, grid: List[List[int]]) -> List[List[int]]:
m, n = len(grid), len(grid[0])
row_ones = [0] * m
col_ones = [0] * n
for i in range(m):
for j in range(n):
row_ones[i] += grid[i][j]
col_ones[j] += grid[i][j]
for i in range(m):
for j in range(n):
grid[i][j] = 2 * (row_ones[i] + col_ones[j]) - m - n
return grid
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.12.18 Today's Challenge (0) | 2023.12.18 |
---|---|
2023.12.17 Today's Challenge (0) | 2023.12.17 |
2023.12.15 Today's Challenge (0) | 2023.12.15 |
2023.12.14 Today's Challenge (0) | 2023.12.14 |
2023.12.13 Today's Challenge (0) | 2023.12.13 |
Comments