All Posts

Leetcode 2447: Number of Subarrays With GCD Equal to K

Given an integer array nums and an integer k, return the number of subarrays in which the greatest common divisor (GCD) of all the elements is exactly k. A subarray is a contiguous non-empty sequence of elements within the array.

Leetcode 2470: Number of Subarrays With LCM Equal to K

Given an integer array nums and an integer k, return the number of subarrays where the Least Common Multiple (LCM) of all the elements in the subarray equals k. A subarray is a contiguous subsequence of elements in the array.

Leetcode 2507: Smallest Value After Replacing With Sum of Prime Factors

You are given a positive integer n. The task is to repeatedly replace n with the sum of its prime factors, and continue this process until n reaches a value that cannot be reduced further. The process stops when the sum of the prime factors is equal to the current value of n. Return the smallest value n will eventually become.

Leetcode 2513: Minimize the Maximum of Two Arrays

Given two integers divisor1 and divisor2, and two integers uniqueCnt1 and uniqueCnt2, construct two arrays such that: arr1 contains uniqueCnt1 distinct integers that are not divisible by divisor1, arr2 contains uniqueCnt2 distinct integers that are not divisible by divisor2, and no integer appears in both arrays. Return the smallest possible maximum integer in either array.

Leetcode 2521: Distinct Prime Factors of Product of Array

Given an array of positive integers nums, find the number of distinct prime factors in the product of all the elements in the array. A prime factor of a number is a number that divides it evenly, and only divisible by 1 and itself. The goal is to calculate the distinct prime factors present in the prime factorization of the product of all elements in nums.

Leetcode 2523: Closest Prime Numbers in Range

Given two integers left and right, find the two prime numbers num1 and num2 such that: left <= num1 < num2 <= right, both are prime numbers, and the difference num2 - num1 is the smallest among all valid pairs. If multiple pairs have the same smallest difference, return the pair with the smallest num1. If no such pair exists, return [-1, -1].