3199. Count Triplets with Even XOR Set Bits I
Given three integer arrays
a
,b
, andc
, return the number of triplets(a[i], b[j], c[k])
, such that the bitwiseXOR
of the elements of each triplet has an even number of set bits.
3199. Count Triplets with Even XOR Set Bits I
Given three integer arrays
a
,b
, andc
, return the number of triplets(a[i], b[j], c[k])
, such that the bitwiseXOR
of the elements of each triplet has an even number of set bits.
3205. Maximum Array Hopping Score I
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
i
to an indexj > i
, and you get a score of(j - i) * nums[j]
.Return the maximum score you can get.
3209. Number of Subarrays With AND Value of K
Given an array of integers
nums
and an integerk
, return the number of subarrays ofnums
where the bitwiseAND
of the elements of the subarray equalsk
.
There is a circle of red and blue tiles. You are given an array of integers
colors
and an integerk
. The color of tilei
is represented bycolors[i]
:
colors[i] == 0
means that tilei
is red.colors[i] == 1
means that tilei
is blue.An alternating group is every
k
contiguous tiles in the circle with alternating colors (each tile in the group except the first and last one has a different color from its left and right tiles).Return the number of alternating groups.
Note that since
colors
represents a circle, the first and the last tiles are considered to be next to each other.
3207. Maximum Points After Enemy Battles
You are given an integer array
enemyEnergies
denoting the energy values of various enemies.You are also given an integer
currentEnergy
denoting the amount of energy you have initially.You start with 0 points, and all the enemies are unmarked initially.
You can perform either of the following operations zero or multiple times to gain points:
Choose an unmarked enemy,
i
, such thatcurrentEnergy >= enemyEnergies[i]
. By choosing this option:
- You gain 1 point.
- Your energy is reduced by the enemy’s energy, i.e.
currentEnergy = currentEnergy - enemyEnergies[i]
.If you have at least 1 point, you can choose an unmarked enemy,
i
. By choosing this option:
- Your energy increases by the enemy’s energy, i.e.
currentEnergy = currentEnergy + enemyEnergies[i]
.- The enemy
i
is marked.Return an integer denoting the maximum points you can get in the end by optimally performing operations.
There is a circle of red and blue tiles. You are given an array of integers
colors
. The color of tilei
is represented bycolors[i]
:
colors[i] == 0
means that tilei
is red.colors[i] == 1
means that tilei
is blue.Every 3 contiguous tiles in the circle with alternating colors (the middle tile has a different color from its left and right tiles) is called an alternating group.
Return the number of alternating groups.
Note that since
colors
represents a circle, the first and the last tiles are considered to be next to each other.
3203. Find Minimum Diameter After Merging Two Trees
There exist two undirected trees with
n
andm
nodes, numbered from0
ton - 1
and from0
tom - 1
, respectively. You are given two 2D integer arraysedges1
andedges2
of lengthsn - 1
andm - 1
, respectively, whereedges1[i] = [ai, bi]
indicates that there is an edge between nodesai
andbi
in the first tree andedges2[i] = [ui, vi]
indicates that there is an edge between nodesui
andvi
in the second tree.You must connect one node from the first tree with another node from the second tree with an edge.
Return the minimum possible diameter of the resulting tree.
The diameter of a tree is the length of the longest path between any two nodes in the tree.
3202. Find the Maximum Length of Valid Subsequence II
You are given an integer array
nums
and a positive integerk
.A subsequence
sub
ofnums
with lengthx
is called valid if it satisfies:
(sub[0] + sub[1]) % k == (sub[1] + sub[2]) % k == ... == (sub[x - 2] + sub[x - 1]) % k.
Return the length of the longest valid subsequence of
nums
.
3201. Find the Maximum Length of Valid Subsequence I
You are given an integer array
nums
.A subsequence
sub
ofnums
with lengthx
is called valid if it satisfies:
(sub[0] + sub[1]) % 2 == (sub[1] + sub[2]) % 2 == ... == (sub[x - 2] + sub[x - 1]) % 2.
Return the length of the longest valid subsequence of
nums
.A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
3200. Maximum Height of a Triangle
You are given two integers
red
andblue
representing the count of red and blue colored balls. You have to arrange these balls to form a triangle such that the 1st row will have 1 ball, the 2nd row will have 2 balls, the 3rd row will have 3 balls, and so on.All the balls in a particular row should be the same color, and adjacent rows should have different colors.
Return the maximum height of the triangle that can be achieved.