Alex is a treasure hunter exploring an ancient temple, represented by a square grid…
- User
Alex is a treasure hunter exploring an ancient temple, represented by a square grid tiles of size nn Each tile of the temple flolds a mysterious number, and Alex has to walk from the entrance at the top-left (0,0) to the treasure room at the bottom-right [n - 1, n - 1]
Alex can move in either the right or bottom direction, which is (i, j) to (i, j + 1) or (i + 1, j) He needs to multiply each number in the path from [0, 0] to [n - 1, n - 1] . But there is a twist: the value of each tile determines how hard it would be to reach the treasure, with some numbers causing his steps to slow down by adding more leading zeros to his progress. Alex's mission is to reach the treasure room with minimum leading zeros in the resulting value.
Help him find the minimum leading zeros with which he can reach the treasure room.
Function description
Complete the solve() function. This function takes the following two parameters and returns an integer:
• n. Represents the dimension of 2D array tiles
• tiles. Represents the 2D array tiles
Input format for custom testing
Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code.
• The next in line contains n integers denoting the elements of array tiles.
Output format
Return an integer representing the answer.
Constraints 1 < n < 1000 0 tiles[i][j] < 10°
Sample input
3 2 3 10
5 10 3
4 2 5 Sample output
2 Explanation
Given
n = 3
spices = [[2, 3, 10], [5, 10, 3], [4, 2, 5]]
Approach
• One of the possible paths can be [0, 0] -> [0, 1] [0, 2] -> [1, 2] -> [2
Approach One of the possible paths can be [0, 0] -> [0, 1] -> [0, 2] -> [1, 2] -> [2. 2].
The value will be 231035 = 900.
• The number of leading zeros is 2, which is the minimum possible.
Note:
Your code must be able to print the sample output from the provided samp input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.
Limits
Time Limit: 2.0 Jec(s) for each input file
Memory Limit: 256 MB
Source Limit: 1024 KB
Scoring
Score is assigned if any test case passes write the python code with time complexity O(n) or less
- Assistant