목록CodingTest/Leetcode (2)
모눈종이에 사각사각

🍎 Letter Combinations of a Phone Number 문제 링크 💿 문제 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. ⚾ 코드 def solution(digits): # 알파벳 매핑 alpha = [[], [], ['a', 'b', '..

🍎 Number of Islands 문제 링크 💿 문제 Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. ⚾ 코드 def solution(grid): W = len(grid[0]) H = len(grid) visited = [[False]*W for _ in range(H)] count = 0 dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] def check_range(x, y): # print(x, y) if x >= 0 and x = 0 and y < W: # print(True) return Tr..