Skip to content

Commit fa0327e

Browse files
committed
refactor
1 parent ff0482e commit fa0327e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

word-search/pmjuu.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ def search(row, col, word_idx, visited):
5151
# => 총 공간 복잡도: O(k)
5252

5353

54+
from collections import Counter
55+
5456
class Solution:
5557
def exist(self, board: list[list[str]], word: str) -> bool:
5658
n, m = len(board), len(board[0])
5759
word_length = len(word)
5860

5961
# 조기 종료: board에 word를 구성할 충분한 문자가 있는지 확인
60-
from collections import Counter
6162
board_counter = Counter(char for row in board for char in row)
6263
word_counter = Counter(word)
6364
if any(word_counter[char] > board_counter[char] for char in word_counter):

0 commit comments

Comments
 (0)