All Posts

Leetcode 1971: Find if Path Exists in Graph

You are given a graph with n vertices labeled from 0 to n-1 (inclusive) and edges connecting pairs of vertices. Your task is to determine if there exists a valid path from a given source vertex to a destination vertex. The graph is undirected, and each pair of vertices is connected by at most one edge. The vertices are connected by edges as given in the input.

Leetcode 1992: Find All Groups of Farmland

You are given an m x n binary matrix representing a piece of land, where ‘1’ denotes farmland and ‘0’ denotes forest. Your task is to identify the coordinates of each rectangular group of contiguous farmland (1’s), where each group of farmland is isolated and not adjacent to another group. Return a list of 4-length arrays, where each array represents the top-left and bottom-right coordinates of a rectangular farmland group.

Leetcode 1993: Operations on Tree

You are given a tree with n nodes numbered from 0 to n - 1 represented by a parent array. You need to implement the LockingTree class with methods for locking, unlocking, and upgrading nodes in the tree based on certain conditions.

Leetcode 2039: The Time When the Network Becomes Idle

You are managing a network of servers connected by communication channels. One server, labeled as 0, acts as the master server, while the others are data servers. Each data server sends a message to the master server at the start and waits for a reply. The reply travels back via the same route the message took. If a server does not receive a reply within a specific period (defined by its patience value), it resends the message. The goal is to determine when the network will become idle, meaning there are no active messages being transmitted or received.

Leetcode 2059: Minimum Operations to Convert Number

You are given a 0-indexed integer array nums, containing distinct numbers, an integer start, and an integer goal. There is an integer x, initially set to start, and you need to transform x into goal by repeatedly performing operations. You can use any number from the array nums in the following ways: x + nums[i], x - nums[i], or x ^ nums[i] (bitwise-XOR). You can perform each operation any number of times in any order. If the resulting number goes outside the range 0 <= x <= 1000, no further operations can be performed. The task is to determine the minimum number of operations required to convert x from start to goal, or return -1 if it is not possible.

Leetcode 2101: Detonate the Maximum Bombs

You are given a list of bombs represented by a 2D array ‘bombs’ where each bomb is described by three integers: [xi, yi, ri]. xi and yi denote the X and Y coordinates of the bomb, while ri is its blast radius. Your task is to find the maximum number of bombs that can be detonated by initiating a detonation of one bomb.