2713. Maximum Strictly Increasing Cells in a Matrix
Given a 1-indexed
m x ninteger matrixmat, you can select any cell in the matrix as your starting cell.From the starting cell, you can move to any other cell in the same row or column, but only if the value of the destination cell is strictly greater than the value of the current cell. You can repeat this process as many times as possible, moving from cell to cell until you can no longer make any moves.
Your task is to find the maximum number of cells that you can visit in the matrix by starting from some cell.
Return an integer denoting the maximum number of cells that can be visited.
2712. Minimum Cost to Make All Characters Equal
You are given a 0-indexed binary string
sof lengthnon which you can apply two types of operations:
- Choose an index
iand invert all characters from index0to indexi(both inclusive), with a cost ofi + 1- Choose an index
iand invert all characters from indexito indexn - 1(both inclusive), with a cost ofn - iReturn the minimum cost to make all characters of the string equal.
Invert a character means if its value is ‘0’ it becomes ‘1’ and vice-versa.
2711. Difference of Number of Distinct Values on Diagonals
Given a 0-indexed 2D
gridof sizem x n, you should find the matrixanswerof sizem x n.The value of each cell
(r, c)of the matrixansweris calculated in the following way:
- Let
topLeft[r][c]be the number of distinct values in the top-left diagonal of the cell(r, c)in the matrixgrid.- Let
bottomRight[r][c]be the number of distinct values in the bottom-right diagonal of the cell(r, c)in the matrixgrid.Then
answer[r][c] = |topLeft[r][c] - bottomRight[r][c]|.Return the matrix
answer.A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix’s end.
A cell
(r1, c1)belongs to the top-left diagonal of the cell(r, c), if both belong to the same diagonal andr1 < r. Similarly is defined bottom-right diagonal.
2710. Remove Trailing Zeros From a String
Given a positive integer
numrepresented as a string, return the integernumwithout trailing zeros as a string.