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