All Posts

Leetcode 1943: Describe the Painting

You are given a painting represented by a number line. Multiple overlapping segments are painted with different colors. Your task is to return a minimal set of non-overlapping painted segments, where each segment represents a portion of the painting with a unique set of mixed colors. Each segment should be represented by the sum of the colors in the mixed sets.

Leetcode 1980: Find Unique Binary String

You are given an array of unique binary strings, each of length n. Your task is to find and return a binary string of length n that is not present in the given array. There can be multiple valid solutions.

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 1995: Count Special Quadruplets

Given a 0-indexed integer array ’nums’, return the number of distinct quadruplets (a, b, c, d) such that:

  • nums[a] + nums[b] + nums[c] == nums[d], and
  • a < b < c < d.

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 2006: Count Number of Pairs With Absolute Difference K

Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.