All Posts

Leetcode 2429: Minimize XOR

You are given two positive integers, num1 and num2. Your task is to find a positive integer x such that: 1. x has the same number of set bits (1’s in binary representation) as num2, and 2. The value of x XOR num1 is minimized. The XOR operation is performed bitwise. Your goal is to return the integer x.

Leetcode 2433: Find The Original Array of Prefix Xor

You are given an integer array pref of size n. Your task is to find and return an array arr of size n that satisfies the following condition: each element pref[i] equals the XOR of all elements from arr[0] to arr[i]. In other words, pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i] where ^ denotes the bitwise XOR operation. It is guaranteed that there is a unique solution.

Leetcode 2438: Range Product Queries of Powers

Given a positive integer n, you need to construct an array called powers that contains the minimum number of powers of 2 that sum up to n. The array powers should be sorted in non-decreasing order. You are also given a set of queries where each query asks for the product of the powers in the powers array between indices left and right (both inclusive). For each query, return the product modulo 10^9 + 7.

Leetcode 2506: Count Pairs Of Similar Strings

You are given a list of words, where each word consists of lowercase English letters. Two words are considered similar if they contain the exact same set of unique characters, regardless of the order. Your task is to count how many pairs of words (i, j) satisfy the condition where both words have the same set of unique characters. Return the count of such pairs (i, j) where 0 ≤ i < j ≤ len(words) - 1.

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 2546: Apply Bitwise Operations to Make Strings Equal

You are given two binary strings s and target of the same length. You can perform an operation on s any number of times to transform it into target. The operation replaces two distinct indices with logical operations. Return true if it’s possible to make s equal to target, otherwise return false.