LeetCode - 150 - Walls and Gates

The problem You are given an m*n 2D grid initialized with these three possible values: -1 - A wall or obstacle. 0 - A gate. INF - Infinity means an empty room. We use the value 2^31 - 1 = 2147483647 to represent INF. Fill each empty room with the distance to its nearest gate. If it’s impossible to reach the gate, it should be filled with INF. Assume the grid can only be traversed up, down, left, or right. ...

October 11, 2025 · 4 min · Dmytro Chumakov

LeetCode - 150 - Max Area of Island

The problem You are given an m x n binary matrix grid. An island is a group of 1s (representing land) connected 4-directionally (horizontally or vertically). You may assume all four edges of the grid are surrounded by water. The area of an island is the number of cells with a value 1 in the island. Return the maximum area of an island in grid. If there is no island, return 0. ...

October 6, 2025 · 3 min · Dmytro Chumakov

LeetCode - 150 - Reverse Nodes in k-Group

The problem Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then the left-out nodes at the end should remain as they are. You may not alter the values in the list’s nodes, only nodes themselves may be changed. ...

October 1, 2025 · 4 min · Dmytro Chumakov

LeetCode - 150 - N-Queens

The problem The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order. Each solution contains a distinct board configuration of the n-queens’ placement, where 'Q' and '.' both indicate a queen and an empty space, respectively. ...

September 26, 2025 · 6 min · Dmytro Chumakov

LeetCode - 150 - Letter Combinations of a Phone Number

The problem 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 digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Examples Input: digits = "23" Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] Input: digits = "" Output: [] Input: digits = "2" Output: ["a","b","c"] Constraints 0 <= digits.length <= 4 digits[i] is a digit in the range [‘2’, ‘9’] Explanation From the description of the problem, we learn that we are given a string with digits from 2-9 and we need to return all possible combinations that the number could represent. ...

September 15, 2025 · 2 min · Dmytro Chumakov