All Posts

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 1996: The Number of Weak Characters in the Game

You are given a list of characters’ properties, where each character has two main attributes: attack and defense. A character is weak if another character exists with both greater attack and defense values. Return the number of weak characters in the list.

Leetcode 1997: First Day Where You Have Been in All the Rooms

You are given a list of rooms and their visiting order for each day based on a set of rules. On each day, you either revisit a room based on the number of visits or proceed to the next room in a cyclic manner. Your task is to find the first day when all rooms have been visited.

Leetcode 2001: Number of Pairs of Interchangeable Rectangles

You are given a list of rectangles, each represented by its width and height. Two rectangles are interchangeable if their width-to-height ratios are the same. Your task is to return the number of interchangeable rectangle pairs in the list.

Leetcode 2002: Maximum Product of the Length of Two Palindromic Subsequences

Given a string s, find two disjoint palindromic subsequences such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.