You are given a 0-indexed two-dimensional integer array
nums.Return the largest prime number that lies on at least one of the diagonals of
nums. In case, no prime is present on any of the diagonals, return 0.Note that:
- An integer is prime if it is greater than
1and has no positive integer divisors other than1and itself.- An integer
valis on one of thediagonals ofnumsif there exists an integerifor whichnums[i][i] = valor anifor whichnums[i][nums.length - i - 1]= val.
In the above diagram, one diagonal is [1,5,9] and another diagonal is [3,5,7].
You are given a 0-indexed integer array
nums. There exists an arrayarrof lengthnums.length, wherearr[i]is the sum of|i - j|over alljsuch thatnums[j] == nums[i]andj != i. If there is no suchj, setarr[i]to be0.Return the array
arr.
2616. Minimize the Maximum Difference of Pairs
You are given a 0-indexed integer array
numsand an integerp. Findppairs of indices ofnumssuch that the maximum difference amongst all the pairs is minimized. Also, ensure no index appears more than once amongst theppairs.Note that for a pair of elements at the index
iandj, the difference of this pair is|nums[i] - nums[j]|, where|x|represents the absolute value ofx.Return the minimum maximum difference among all
ppairs.
2617. Minimum Number of Visited Cells in a Grid
You are given a 0-indexed
m x ninteger matrixgrid. Your initial position is at the top-left cell(0, 0).Starting from the cell
(i, j), you can move to one of the following cells:
- Cells
(i, k)withj < k <= grid[i][j] + j(rightward movement), or- Cells
(k, j)withi < k <= grid[i][j] + i(downward movement).Return the minimum number of cells you need to visit to reach the bottom-right cell
(m - 1, n - 1). If there is no valid path, return-1.