You are given two numeric strings
num1andnum2and two integersmax_sumandmin_sum. We denote an integerxto be good if:
num1 <= x <= num2min_sum <= digit_sum(x) <= max_sum.Return the number of good integers. Since the answer may be large, return it modulo
109 + 7.Note that
digit_sum(x)denotes the sum of the digits ofx.
2718. Sum of Matrix After Queries
You are given an integer
nand a 0-indexed 2D arrayquerieswherequeries[i] = [typei, indexi, vali].Initially, there is a 0-indexed
n x nmatrix filled with0‘s. For each query, you must apply one of the following changes:
- if
typei == 0, set the values in the row withindexitovali, overwriting any previous values.- if
typei == 1, set the values in the column withindexitovali, overwriting any previous values.Return the sum of integers in the matrix after all queries are applied.
2717. Semi-Ordered Permutation
You are given a 0-indexed permutation of
nintegersnums.A permutation is called semi-ordered if the first number equals
1and the last number equalsn. You can perform the below operation as many times as you want until you makenumsa semi-ordered permutation:
- Pick two adjacent elements in
nums, then swap them.Return the minimum number of operations to make
numsa semi-ordered permutation.A permutation is a sequence of integers from
1tonof lengthncontaining each number exactly once.
Given a 0-indexed string
s, repeatedly perform the following operation any number of times:
- Choose an index
iin the string, and letcbe the character in positioni. Delete the closest occurrence ofcto the left ofi(if any) and the closest occurrence ofcto the right ofi(if any).Your task is to minimize the length of
sby performing the above operation any number of times.Return an integer denoting the length of the minimized string.