LeetCode - 150 - Surrounded Regions

The problem You are given an m x n matrix board containing letters 'X' and 'O', capture regions that are surrounded: Connect: A cell is connected to adjacent cells horizontally or vertically. Region: To form a region connect every 'O' cell. Surround: The region is surrounded with 'X' cells if you can connect the region with 'X' cells and none of the region cells are on the edge of the board. To capture a surrounded region, replace all 'O's with 'X's in-place within the original board. You do not need to return anything. ...

October 21, 2025 · 3 min · Dmytro Chumakov

LeetCode - 150 - Rotting Oranges

The problem You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten. Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1. ...

October 17, 2025 · 5 min · Dmytro Chumakov

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