All Posts

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 2516: Take K of Each Character From Left and Right

You are given a string s consisting of the characters ‘a’, ‘b’, and ‘c’, and a non-negative integer k. Each minute, you can choose to take either the leftmost or the rightmost character from s. Your task is to determine the minimum number of minutes required to collect at least k occurrences of each character (‘a’, ‘b’, and ‘c’). If it is not possible to collect k of each character, return -1.

Leetcode 2517: Maximum Tastiness of Candy Basket

You are given an array of positive integers price where price[i] denotes the price of the i-th candy and a positive integer k. The store sells baskets containing k distinct candies. The tastiness of a candy basket is defined as the smallest absolute difference between the prices of any two candies in the basket. Your task is to return the maximum tastiness of a candy basket that can be formed by selecting k distinct candies.

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 2522: Partition String Into Substrings With Values at Most K

Given a string s consisting of digits between 1 and 9, and an integer k, you need to partition the string into the fewest possible substrings such that the value of each substring is less than or equal to k. Each substring must consist of contiguous digits and must be interpreted as an integer. If it’s not possible to partition the string in such a way, return -1.

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].