All Posts

Leetcode 128: Longest Consecutive Sequence

Given an unsorted array of integers, return the length of the longest consecutive elements sequence.

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 399: Evaluate Division

You are given a list of equations and their corresponding values, where each equation represents a division between two variables. Your task is to determine the result of several queries asking for the division result of two given variables.

Leetcode 547: Number of Provinces

You are given a matrix where each element indicates if two cities are directly connected. Your task is to determine the number of provinces formed by the cities. A province is a group of directly or indirectly connected cities.

Leetcode 684: Redundant Connection

You are given a graph that started as a tree with n nodes. One additional edge has been added, creating a cycle. Your task is to find and return the redundant edge that, when removed, would turn the graph back into a tree.