All Posts

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.

Leetcode 2013: Detect Squares

You are given a stream of 2D points on the XY-plane. Your task is to design an algorithm that adds new points into a data structure and counts how many sets of three points, along with a given query point, can form an axis-aligned square. An axis-aligned square is a square where the edges are parallel or perpendicular to the X-axis and Y-axis, with all sides of equal length.

Leetcode 2023: Number of Pairs of Strings With Concatenation Equal to Target

You are given an array of digit strings nums and a target digit string target. Count the number of valid pairs of indices (i, j) where i != j such that the concatenation of nums[i] and nums[j] equals target.

Leetcode 2029: Stone Game IX

Alice and Bob are playing a game with stones. The sequence of n stones has values given in an array stones. Players take turns to remove a stone. The player who removes a stone, making the sum of all removed stones divisible by 3, loses. If all stones are removed, Bob wins automatically. Determine if Alice wins or Bob wins, assuming both play optimally.

Leetcode 2053: Kth Distinct String in an Array

Find the k-th unique string in an array based on its first occurrence. If fewer than k unique strings exist, return an empty string.