All Posts

Leetcode 2859: Sum of Values at Indices With K Set Bits

Given a list of integers and an integer k, return the sum of all elements whose indices have exactly k set bits in their binary representation.

Leetcode 2869: Minimum Operations to Collect Elements

You are given an array nums containing positive integers and an integer k. In each operation, you can remove the last element from the array and add it to your collection. Your task is to determine the minimum number of operations needed to collect all elements from 1 to k (inclusive).

Leetcode 2871: Split Array Into Maximum Number of Subarrays

You are given an array nums consisting of non-negative integers. Your task is to divide the array into subarrays such that the sum of the scores of the subarrays is minimized. The score of a subarray nums[l..r] is defined as nums[l] AND nums[l + 1] AND … AND nums[r], where AND is the bitwise AND operation. Your goal is to return the maximum number of subarrays that you can split the array into while achieving the minimum possible sum of scores.

Leetcode 2917: Find the K-or of an Array

You are given an integer array nums and an integer k. We define the K-or operation as follows: for each bit position, the bit in the result will be set to 1 if at least k numbers in the array nums have a 1 in that position. Return the K-or of the array nums.

Leetcode 2932: Maximum Strong Pair XOR I

You are given a 0-indexed array ’nums’. A pair of integers ‘x’ and ‘y’ is called a strong pair if it satisfies the condition |x - y| <= min(x, y). Your task is to find two integers from ’nums’ that form a strong pair and have the highest possible bitwise XOR value among all strong pairs in the array. You can pick the same integer twice.