All Posts

Leetcode 2657: Find the Prefix Common Array of Two Arrays

You are given two integer arrays A and B, each of length n, which are permutations of numbers from 1 to n. You need to find the prefix common array of A and B. The prefix common array is defined as an array C where each C[i] represents the number of integers that appear at or before index i in both A and B.

Leetcode 2680: Maximum OR

You are given a 0-indexed integer array nums of length n and an integer k. In each operation, you can pick an element from the array and multiply it by 2. Your goal is to determine the maximum possible value of the bitwise OR of all elements in the array after applying the operation at most k times.

Leetcode 2683: Neighboring Bitwise XOR

You are given a binary array derived of length n. The derived array is obtained by computing the bitwise XOR of adjacent values in an original binary array. Specifically, for each index i, if i is the last index, derived[i] = original[i] ⊕ original[0], otherwise, derived[i] = original[i] ⊕ original[i + 1]. The task is to determine if there exists a valid binary array original that could have formed the given derived array.

Leetcode 2708: Maximum Strength of a Group

You are given an integer array representing the scores of students in an exam. Your task is to form a non-empty group of students such that the group’s strength, defined as the product of their scores, is maximized. The goal is to return the maximum possible strength that can be achieved by choosing an optimal group of students.

Leetcode 2741: Special Permutations

You are given a list of distinct positive integers nums. A permutation of nums is considered special if, for every pair of consecutive numbers in the permutation, one number is divisible by the other. Your task is to return the total number of special permutations of nums, modulo 10^9 + 7.

Leetcode 2857: Count Pairs of Points With Distance k

Given a list of 2D points and an integer k, find the number of pairs of points whose distance (calculated as XOR sum of their coordinates) equals k.