[Swift] LeetCode1301 score the maximum number of paths |. Number of Paths with Max Score

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤ micro-channel public number: Shan Wing Chi ( let_us_code)
➤ bloggers domain: https://www.zengqiang.org
➤GitHub address: https://github.com/strengthen/LeetCode
➤ original address: https://www.cnblogs.com/strengthen/p/12151653 .html
➤ If the address is not a link blog Park Yong Shan Chi, it may be crawling author of the article.
➤ text has been modified update! Click strongly recommended that the original address read! Support authors! Support the original!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

You are given a square board of characters. You can move on the board starting at the bottom right square marked with the character 'S'.

You need to reach the top left square marked with the character 'E'. The rest of the squares are labeled either with a numeric character 1, 2, ..., 9 or with an obstacle 'X'. In one move you can go up, left or up-left (diagonally) only if there is no obstacle there.

Return a list of two integers: the first integer is the maximum sum of numeric characters you can collect, and the second is the number of such paths that you can take to get that maximum sum, taken modulo 10^9 + 7.

In case there is no path, return [0, 0].

 

Example 1:

Input: board = ["E23","2X2","12S"]
Output: [7,1]
Example 2:

Input: board = ["E12","1X1","21S"]
Output: [4,2]
Example 3:

Input: board = ["E11","XXX","11S"]
Output: [0,0]
 

Constraints:

2 <= board.length == board[i].length <= 100


Give you a square array of characters board, you start from the bottom right most array of character 'S'.

Your goal is to reach the top left corner of the array of characters 'E', an array of the remaining part of the numeric characters 1, 2, ..., 9 or obstacles 'X'. In every step of the move, you can move up, move left or upper left, you can move on the premise that there are no obstacles to reach grid.

A path of "score" is defined as: and on the path of all numbers.

Please return a list containing two integers: the first integer is the maximum "score", and the second integer is the number of the program to get maximum score, make the results of the 10 ^ 9 + 7 modulo.

If no path can reach the end, return to [0, 0].

 

Example 1:

Input: board = [ "E23", "2X2", "12S"]
Output: [7,1]
Example 2:

Input: board = [ "E12", "1X1", "21S"]
Output: [4,2]
Example 3:

Input: board = [ "E11", "XXX", "11S"]
Output: [0,0]
 

prompt:

2 <= board.length == board[i].length <= 100

Guess you like

Origin www.cnblogs.com/strengthen/p/12151653.html