All Posts

Leetcode 73: Set Matrix Zeroes

You are given an m x n matrix of integers. Whenever an element in the matrix is 0, you need to set all elements in the corresponding row and column to 0, but the operation must be done in place. This means you cannot use extra space for another matrix.

Leetcode 74: Search a 2D Matrix

You are given an m x n matrix where each row is sorted in non-decreasing order, and the first integer of each row is greater than the last integer of the previous row. Given a target integer, return true if the target exists in the matrix or false otherwise. The solution must have a time complexity of O(log(m * n)).

Leetcode 79: Word Search

You are given a 2D grid board containing characters and a string word. The task is to determine whether the given word can be formed by starting at any cell in the grid and moving to adjacent cells, which are horizontally or vertically neighboring. The same cell cannot be reused in forming the word.

Leetcode 130: Surrounded Regions

You are given an m x n matrix board containing letters ‘X’ and ‘O’. Capture all regions that are surrounded by ‘X’. A region is captured if it is surrounded by ‘X’ cells and cannot reach the edges of the board.

Leetcode 200: Number of Islands

You are given a 2D grid representing a map, where ‘1’ represents land and ‘0’ represents water. Your task is to count how many islands are formed by connecting adjacent lands horizontally or vertically. An island is a collection of ‘1’s connected either horizontally or vertically.

Leetcode 378: Kth Smallest Element in a Sorted Matrix

Given an n x n matrix where each row and column is sorted in ascending order, find the kth smallest element in the matrix. The matrix is sorted in both rows and columns, but the kth smallest element is the one in the sorted order, not necessarily distinct.