All Posts

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 2527: Find Xor-Beauty of Array

You are given an integer array nums. The xor-beauty of the array is the XOR of the effective values of all possible triplets of indices (i, j, k) where 0 <= i, j, k < n. The effective value for each triplet is calculated as ((nums[i] | nums[j]) & nums[k]).

Leetcode 2529: Maximum Count of Positive Integer and Negative Integer

You are given an array of integers sorted in non-decreasing order. Your task is to determine the maximum count between the number of positive integers and the number of negative integers in the array. Zero is not considered positive or negative.

Leetcode 2530: Maximal Score After Applying K Operations

You are given a list of integers nums and an integer k. In each operation, you choose an index i, increase your score by nums[i], and replace nums[i] with ceil(nums[i] / 3). Apply exactly k operations and return the maximum score you can achieve.

Leetcode 2535: Difference Between Element Sum and Digit Sum of an Array

Given a positive integer array nums, compute the absolute difference between the element sum and the digit sum of the elements in the array.