Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 합성곱 신경망
- 이상탐지
- deep learning
- 데이터 파싱
- visual instruction tuning
- rrf
- 활성화함수
- rag parsing
- anomaly detection
- E
- pdf parsing
- 컴퓨터비전
- 손실함수
- rag-fusion
- multi-query
- Mean squared error
- Cross Entropy Error
- 오차역전파
- Time Series
- segmentation
- 시계열
- computer vision
- LLM
- 활성화 함수
- nlp
- LLaVA
- leetcode
- 딥러닝
- 퍼셉트론
- Non-Maximum Suppression
Archives
- Today
- Total
굴러가는 분석가의 일상
[LeetCode] Valid Sudoku 본문
문제
풀이
class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
rows = collections.defaultdict(set)
cols = collections.defaultdict(set)
squares = collections.defaultdict(set)
# 1. 9X9 Grid 만든다
for r in range(9):
for c in range(9):
# 2. "."와 같이 비어있는 값이 있는지 파악을 합니다. 이에 빈칸이라면, 계속해서 loop를 돌립니다.
if board[r][c] == ".":
continues
# 3. 중복되는 값이 있다면 loop를 종료 시킵니다.
if(board[r][c] in rows[r] or
board[r][c] in cols[c] or
board[r][c] in squares[(r//3),(c//3)]):
return False
rows[r].add(board[r][c])
cols[c].add(board[r][c])
squares[(r//3),(c//3).add(board[r][c])
return True
'Algorithm > Leetcode' 카테고리의 다른 글
[LeetCode] Valid Anagram (0) | 2024.02.16 |
---|---|
[LeetCode] Product of Array Except Self (0) | 2023.12.14 |
[LeetCode] SQL 50문제 (진행중) (0) | 2023.10.24 |
[LeetCode] Two Sum (0) | 2023.10.20 |
[LeetCode] Contains Duplicate (0) | 2023.10.10 |