[LeetCode] Maximum XOR of Subsequences

3681. Maximum XOR of Subsequences

You are given an integer array nums of length n where each element is a non-negative integer.

Select two subsequences of nums (they may be empty and are allowed to overlap), each preserving the original order of elements, and let:

  • X be the bitwise XOR of all elements in the first subsequence.
  • Y be the bitwise XOR of all elements in the second subsequence.

Return the maximum possible value of X XOR Y.

Note: The XOR of an empty subsequence is 0.

Read more
[LeetCode] Generate Schedule

3680. Generate Schedule

You are given an integer n representing n teams. You are asked to generate a schedule such that:

  • Each team plays every other team exactly twice: once at home and once away.
  • There is exactly one match per day; the schedule is a list of consecutive days and schedule[i] is the match on day i.
  • No team plays on consecutive days.

Return a 2D integer array schedule, where schedule[i][0] represents the home team and schedule[i][1] represents the away team. If multiple schedules meet the conditions, return any one of them.

If no schedule exists that meets the conditions, return an empty array.

Read more
[LeetCode] Minimum Discards to Balance Inventory

3679. Minimum Discards to Balance Inventory

You are given two integers w and m, and an integer array arrivals, where arrivals[i] is the type of item arriving on day i (days are 1-indexed).

Items are managed according to the following rules:

  • Each arrival may be kept or discarded; an item may only be discarded on its arrival day.

  • For each day i, consider the window of days [max(1, i - w + 1), i] (the w most recent days up to day i):

    • For any such window, each item type may appear at most m times among kept arrivals whose arrival day lies in that window.
    • If keeping the arrival on day i would cause its type to appear more than m times in the window, that arrival must be discarded.

Return the minimum number of arrivals to be discarded so that every w-day window contains at most m occurrences of each type.

Read more
[LeetCode] Smallest Absent Positive Greater Than Average

3678. Smallest Absent Positive Greater Than Average

You are given an integer array nums.

Return the smallest absent positive integer in nums such that it is strictly greater than the average of all elements in nums.

The average of an array is defined as the sum of all its elements divided by the number of elements.

Read more
[LeetCode] Maximum Number of Words You Can Type

1935. Maximum Number of Words You Can Type

There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.

Given a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you can fully type using this keyboard.

Read more
[LeetCode] Convert Integer to the Sum of Two No-Zero Integers

1317. Convert Integer to the Sum of Two No-Zero Integers

No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.

Given an integer n, return a list of two integers [a, b] where:

  • a and b are No-Zero integers.
  • a + b = n

The test cases are generated so that there is at least one valid solution. If there are many valid solutions, you can return any of them.

Read more
[LeetCode] Find N Unique Integers Sum up to Zero

1304. Find N Unique Integers Sum up to Zero

Given an integer n, return any array containing n unique integers such that they add up to 0.

Read more
[LeetCode] Sum of Beautiful Subsequences

3671. Sum of Beautiful Subsequences

You are given an integer array nums of length n.

For every positive integer g, we define the beauty of g as the product of g and the number of strictly increasing subsequences of nums whose greatest common divisor (GCD) is exactly g.

Return the sum of beauty values for all positive integers g.

Since the answer could be very large, return it modulo 109 + 7.

Read more
[LeetCode] Maximum Product of Two Integers With No Common Bits

3670. Maximum Product of Two Integers With No Common Bits

You are given an integer array nums.

Your task is to find two distinct indices i and j such that the product nums[i] * nums[j] is maximized, and the binary representations of nums[i] and nums[j] do not share any common set bits.

Return the maximum possible product of such a pair. If no such pair exists, return 0.

Read more
[LeetCode] Balanced K-Factor Decomposition

3669. Balanced K-Factor Decomposition

Given two integers n and k, split the number n into exactly k positive integers such that the product of these integers is equal to n.

Return any one split in which the maximum difference between any two numbers is minimized. You may return the result in any order.

Read more