[LeetCode] Maximum Number of Subsequences After One Inserting

3628. Maximum Number of Subsequences After One Inserting

You are given a string s consisting of uppercase English letters.

You are allowed to insert at most one uppercase English letter at any position (including the beginning or end) of the string.

Return the maximum number of "LCT" subsequences that can be formed in the resulting string after at most one insertion.

Read more
[LeetCode] Minimum Jumps to Reach End via Prime Teleportation

3629. Minimum Jumps to Reach End via Prime Teleportation

You are given an integer array nums of length n.

You start at index 0, and your goal is to reach index n - 1.

From any index i, you may perform one of the following operations:

  • Adjacent Step: Jump to index i + 1 or i - 1, if the index is within bounds.
  • Prime Teleportation: If nums[i] is a prime number p, you may instantly jump to any index j != i such that nums[j] % p == 0.

Return the minimum number of jumps required to reach index n - 1.

Read more
[LeetCode] Partition Array for Maximum XOR and AND

3630. Partition Array for Maximum XOR and AND

You are given an integer array nums.

Partition the array into three (possibly empty) subsequences A, B, and C such that every element of nums belongs to exactly one subsequence.

Your goal is to maximize the value of: XOR(A) + AND(B) + XOR(C)

where:

  • XOR(arr) denotes the bitwise XOR of all elements in arr. If arr is empty, its value is defined as 0.
  • AND(arr) denotes the bitwise AND of all elements in arr. If arr is empty, its value is defined as 0.

Return the maximum value achievable.

Note: If multiple partitions result in the same maximum sum, you can consider any one of them.

Read more
[LeetCode] Subarrays with XOR at Least K

3632. Subarrays with XOR at Least K

Given an array of positive integers nums of length n and a non‑negative integer k.

Return the number of contiguous subarrays whose bitwise XOR of all elements is greater than or equal to k.

Read more
[LeetCode] Concatenate Non-Zero Digits and Multiply by Sum II

3756. Concatenate Non-Zero Digits and Multiply by Sum II

You are given a string s of length m consisting of digits. You are also given a 2D integer array queries, where queries[i] = [l_i, r_i].

For each queries[i], extract the substring s[l_i..r_i]. Then, perform the following:

  • Form a new integer x by concatenating all the non-zero digits from the substring in their original order. If there are no non-zero digits, x = 0.
  • Let sum be the sum of digits in x. The answer is x * sum.

Return an array of integers answer where answer[i] is the answer to the i^th query.

Since the answers may be very large, return them modulo 10^9 + 7.

Read more
[LeetCode] Count Elements With at Least K Greater Values

3759. Count Elements With at Least K Greater Values

You are given an integer array nums of length n and an integer k.

An element in nums is said to be qualified if there exist at least k elements in the array that are strictly greater than it.

Return an integer denoting the total number of qualified elements in nums.

Read more
[LeetCode] Find Maximum Balanced XOR Subarray Length

3755. Find Maximum Balanced XOR Subarray Length

Given an integer array nums, return the length of the longest subarray that has a bitwise XOR of zero and contains an equal number of even and odd numbers. If no such subarray exists, return 0.

Read more
[LeetCode] Number of Effective Subsequences

3757. Number of Effective Subsequences

You are given an integer array nums.

The strength of the array is defined as the bitwise OR of all its elements.

A subsequence is considered effective if removing that subsequence strictly decreases the strength of the remaining elements.

Return the number of effective subsequences in nums. Since the answer may be large, return it modulo 10^9 + 7.

The bitwise OR of an empty array is 0.

Read more
[LeetCode] Complete Prime Number

3765. Complete Prime Number

You are given an integer num.

A number num is called a Complete Prime Number if every prefix and every suffix of num is prime.

Return true if num is a Complete Prime Number, otherwise return false.

Note:

  • A prefix of a number is formed by the first k digits of the number.
  • A suffix of a number is formed by the last k digits of the number.
  • Single-digit numbers are considered Complete Prime Numbers only if they are prime.
Read more
[LeetCode] Maximum Substrings With Distinct Start

3760. Maximum Substrings With Distinct Start

You are given a string s consisting of lowercase English letters.

Return an integer denoting the maximum number of substrings you can split s into such that each substring starts with a distinct character (i.e., no two substrings start with the same character).

Read more