3420. Count Non-Decreasing Subarrays After K Operations
You are given an array
numsofnintegers and an integerk.For each subarray of
nums, you can apply up tokoperations on it. In each operation, you increment any element of the subarray by 1.Note that each subarray is considered independently, meaning changes made to one subarray do not persist to another.
Return the number of subarrays that you can make non-decreasing after performing at most
koperations.An array is said to be non-decreasing if each element is greater than or equal to its previous element, if it exists.
3419. Minimize the Maximum Edge Weight of Graph
You are given two integers,
nandthreshold, as well as a directed weighted graph ofnnodes numbered from 0 ton - 1. The graph is represented by a 2D integer arrayedges, whereedges[i] = [Ai, Bi, Wi]indicates that there is an edge going from nodeAito nodeBiwith weightWi.You have to remove some edges from this graph (possibly none), so that it satisfies the following conditions:
- Node 0 must be reachable from all other nodes.
- The maximum edge weight in the resulting graph is minimized.
- Each node has at most
thresholdoutgoing edges.Return the minimum possible value of the maximum edge weight after removing the necessary edges. If it is impossible for all conditions to be satisfied, return -1.
3418. Maximum Amount of Money Robot Can Earn
You are given an
m x ngrid. A robot starts at the top-left corner of the grid(0, 0)and wants to reach the bottom-right corner(m - 1, n - 1). The robot can move either right or down at any point in time.The grid contains a value
coins[i][j]in each cell:
- If
coins[i][j] >= 0, the robot gains that many coins.- If
coins[i][j] < 0, the robot encounters a robber, and the robber steals the absolute value ofcoins[i][j]coins.The robot has a special ability to neutralize robbers in at most 2 cells on its path, preventing them from stealing coins in those cells.
Note: The robot’s total coins can be negative.
Return the maximum profit the robot can gain on the route.
3417. Zigzag Grid Traversal With Skip
You are given an
m x n2D arraygridof positive integers.Your task is to traverse
gridin a zigzag pattern while skipping every alternate cell.Zigzag pattern traversal is defined as following the below actions:
- Start at the top-left cell
(0, 0).- Move right within a row until the end of the row is reached.
- Drop down to the next row, then traverse left until the beginning of the row is reached.
- Continue alternating between right and left traversal until every row has been traversed.
Note that you must skip every alternate cell during the traversal.
Return an array of integers
resultcontaining, in order, the value of the cells visited during the zigzag traversal with skips.