2906. Construct Product Matrix
Given a 0-indexed 2D integer matrix
gridof sizen * m, we define a 0-indexed 2D matrixpof sizen * mas the product matrix ofgridif the following condition is met:
- Each element
p[i][j]is calculated as the product of all elements ingridexcept for the elementgrid[i][j]. This product is then taken modulo12345.Return the product matrix of
grid.
2905. Find Indices With Index and Value Difference II
You are given a 0-indexed integer array
numshaving lengthn, an integerindexDifference, and an integervalueDifference.Your task is to find two indices
iandj, both in the range[0, n - 1], that satisfy the following conditions:
abs(i - j) >= indexDifference, andabs(nums[i] - nums[j]) >= valueDifferenceReturn an integer array
answer, whereanswer = [i, j]if there are two such indices, andanswer = [-1, -1]otherwise. If there are multiple choices for the two indices, return any of them.Note:
iandjmay be equal.
2904. Shortest and Lexicographically Smallest Beautiful String
You are given a binary string
sand a positive integerk.A substring of
sis beautiful if the number of1‘s in it is exactlyk.Let
lenbe the length of the shortest beautiful substring.Return the lexicographically smallest beautiful substring of string
swith length equal tolen. Ifsdoesn’t contain a beautiful substring, return an empty string.A string
ais lexicographically larger than a stringb(of the same length) if in the first position whereaandbdiffer,ahas a character strictly larger than the corresponding character inb.
- For example,
"abcd"is lexicographically larger than"abcc"because the first position they differ is at the fourth character, anddis greater thanc.
2903. Find Indices With Index and Value Difference I
You are given a 0-indexed integer array
numshaving lengthn, an integerindexDifference, and an integervalueDifference.Your task is to find two indices
iandj, both in the range[0, n - 1], that satisfy the following conditions:
abs(i - j) >= indexDifference, andabs(nums[i] - nums[j]) >= valueDifferenceReturn an integer array
answer, whereanswer = [i, j]if there are two such indices, andanswer = [-1, -1]otherwise. If there are multiple choices for the two indices, return any of them.Note:
iandjmay be equal.
2901. Longest Unequal Adjacent Groups Subsequence II
You are given an integer
n, a 0-indexed string arraywords, and a 0-indexed arraygroups, both arrays having lengthn.The hamming distance between two strings of equal length is the number of positions at which the corresponding characters are different.
You need to select the longest subsequence from an array of indices
[0, 1, ..., n - 1], such that for the subsequence denoted as[i0, i1, ..., ik - 1]having lengthk, the following holds:
- For adjacent indices in the subsequence, their corresponding groups are unequal, i.e.,
groups[ij] != groups[ij + 1], for eachjwhere0 < j + 1 < k.words[ij]andwords[ij + 1]are equal in length, and the hamming distance between them is1, where0 < j + 1 < k, for all indices in the subsequence.Return a string array containing the words corresponding to the indices (in order) in the selected subsequence. If there are multiple answers, return any of them.
A subsequence of an array is a new array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.
Note: strings in
wordsmay be unequal in length.