3215. Count Triplets with Even XOR Set Bits II
Given three integer arrays
a,b, andc, return the number of triplets(a[i], b[j], c[k]), such that the bitwiseXORbetween the elements of each triplet has an even number of set bits.
3215. Count Triplets with Even XOR Set Bits II
Given three integer arrays
a,b, andc, return the number of triplets(a[i], b[j], c[k]), such that the bitwiseXORbetween the elements of each triplet has an even number of set bits.
3744. Find Kth Character in Expanded String
You are given a string
sconsisting of one or more words separated by single spaces. Each word insconsists of lowercase English letters.We obtain the expanded string
tfromsas follows:
- For each word in
s, repeat its first character once, then its second character twice, and so on.For example, if
s = "hello world", thent = "heelllllllooooo woorrrllllddddd".You are also given an integer
k, representing a valid index of the stringt.Return the
kthcharacter of the stringt.
3647. Maximum Weight in Two Bags
You are given an integer array
weightsand two integersw1andw2representing the maximum capacities of two bags.Each item may be placed in at most one bag such that:
- Bag 1 holds at most
w1total weight.- Bag 2 holds at most
w2total weight.Return the maximum total weight that can be packed into the two bags.
3610. Minimum Number of Primes to Sum to Target
You are given two integers
nandm.You have to select a multiset of prime numbers from the first
mprime numbers such that the sum of the selected primes is exactlyn. You may use each prime number multiple times.Return the minimum number of prime numbers needed to sum up to
n, or -1 if it is not possible.
3253. Construct String with Minimum Cost (Easy)
You are given a string
target, an array of stringswords, and an integer arraycosts, both arrays of the same length.Imagine an empty string
s.You can perform the following operation any number of times (including zero):
- Choose an index
iin the range[0, words.length - 1].- Append
words[i]tos.- The cost of operation is
costs[i].Return the minimum cost to make
sequal totarget. If it’s not possible, return -1.
3460. Longest Common Prefix After at Most One Removal
You are given two strings
sandt.Return the length of the longest common prefix between
sandtafter removing at most one character froms.Note:
scan be left without any removal.
3221. Maximum Array Hopping Score II
Given an array
nums, you have to get the maximum score starting from index 0 and hopping until you reach the last element of the array.In each hop, you can jump from index
ito an indexj > i, and you get a score of(j - i) * nums[j].Return the maximum score you can get.
3672. Sum of Weighted Modes in Subarrays
You are given an integer array
numsand an integerk.For every subarray of length
k:
- The mode is defined as the element with the highest frequency. If there are multiple choices for a mode, the smallest such element is taken.
- The weight is defined as
mode * frequency(mode).Return the sum of the weights of all subarrays of length
k.Note:
- A subarray is a contiguous non-empty sequence of elements within an array.
- The frequency of an element
xis the number of times it occurs in the array.
Mario drives on a two-lane freeway with coins every mile. You are given two integer arrays,
lane1andlane2, where the value at theithindex represents the number of coins he gains or loses in theithmile in that lane.
- If Mario is in lane 1 at mile
iandlane1[i] > 0, Mario gainslane1[i]coins.- If Mario is in lane 1 at mile
iandlane1[i] < 0, Mario pays a toll and losesabs(lane1[i])coins.- The same rules apply for
lane2.Mario can enter the freeway anywhere and exit anytime after traveling at least one mile. Mario always enters the freeway on lane 1 but can switch lanes at most 2 times.
A lane switch is when Mario goes from lane 1 to lane 2 or vice versa.
Return the maximum number of coins Mario can earn after performing at most 2 lane switches.
Note: Mario can switch lanes immediately upon entering or just before exiting the freeway.
3496. Maximize Score After Pair Deletions
You are given an array of integers
nums. You must repeatedly perform one of the following operations while the array has more than two elements:
- Remove the first two elements.
- Remove the last two elements.
- Remove the first and last element.
For each operation, add the sum of the removed elements to your total score.
Return the maximum possible score you can achieve.