All Posts

Leetcode 1952: Three Divisors

Given an integer n, return true if n has exactly three distinct positive divisors. Otherwise, return false. A divisor of n is a positive integer that divides n without leaving a remainder.

Leetcode 1969: Minimum Non-Zero Product of the Array Elements

You are given a positive integer p. Consider an array nums (1-indexed) that consists of the integers in the inclusive range [1, 2p - 1] represented in binary form. You are allowed to perform the following operation any number of times: Choose two elements x and y from nums. Choose a bit in x and swap it with its corresponding bit in y. The goal is to find the minimum non-zero product of the elements in nums after performing the above operation any number of times. Return this minimum product modulo (10^9 + 7).

Leetcode 1979: Find Greatest Common Divisor of Array

Given an array of integers, your task is to compute the greatest common divisor (GCD) of the smallest and largest elements in the array.

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 2028: Find Missing Observations

You are given an array of m observations, each representing a die roll from a 6-sided die, and an average value mean of all n + m rolls. Your task is to calculate the missing n observations such that the overall average of all n + m rolls equals the provided mean. If multiple valid answers exist, return any of them. If it is impossible to achieve the desired average, return an empty array.

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.