All Posts

Leetcode 957: Prison Cells After N Days

You are given a row of 8 prison cells, where each cell is either occupied or vacant. The state of the cells changes every day according to the following rules: If a cell has two adjacent neighbors that are either both occupied or both vacant, the cell becomes occupied; otherwise, it becomes vacant. The first and last cells don’t have two neighbors, so they are excluded from the rule. You need to determine the state of the cells after ’n’ days of changes.

Leetcode 963: Minimum Area Rectangle II

You are given a set of points in a 2D plane, represented as an array where each point is in the format [xi, yi]. Your task is to find the minimum possible area of any rectangle formed by these points, where the sides of the rectangle do not need to be parallel to the X or Y axes. If no rectangle can be formed, return 0. Answers within 10^-5 of the actual area are considered correct.

Leetcode 970: Powerful Integers

Given three integers x, y, and bound, find all powerful integers that are less than or equal to bound. A powerful integer can be expressed in the form x^i + y^j for non-negative integers i and j. Return the results as a list with no duplicates, and the order of the elements does not matter.

Leetcode 973: K Closest Points to Origin

Given an array of points on a 2D plane, find the k closest points to the origin (0, 0) based on Euclidean distance. If multiple points have the same distance, any order is acceptable.

Leetcode 991: Broken Calculator

You are given a broken calculator that displays an integer ‘startValue’. In each operation, you can either multiply the number by 2 or subtract 1. Your task is to determine the minimum number of operations needed to transform ‘startValue’ into ’target’.

Leetcode 1006: Clumsy Factorial

Given a positive integer n, compute the ‘clumsy factorial’ of n. A clumsy factorial is computed using a series of operations (multiplication, division, addition, subtraction) in a fixed order applied to the integers from n down to 1. The operations follow this order: multiplication ‘*’, division ‘/’, addition ‘+’, subtraction ‘-’, and are repeated cyclically. Division is performed as floor division, and multiplication and division are processed left to right before addition and subtraction.