DPWORLD Coding Question – Solved

10 Live
A forklift operator navigates products within an automotive parts warehouse. The dashboard displays a real-time map showing open and blocked sections as an n x m matrix of 1's (open) and 0's (blocked). The operator starts at the top-left corner of the map at warehouse[0][0] and aims to reach the bottom-right corner at warehouse[n-1][m-1]. Movements can only be made to the right or downward. Given the warehouse map, calculate the number of distinct paths from warehouse[0][0] to warehouse[n-1][m-1]. Return the result modulo (10^9 + 7). Example: warehouse = [1, 1, 0, 1], [1, 1, 1, 1] This matrix shows open (1) and blocked (0) sections of the warehouse. It is only possible to travel through open sections, so no path can go through the section at (0, 2). There are 2 possible paths from warehouse[0][0] to warehouse[1][3], and 2 modulo (10^9 + 7) = 2. Function Description Complete the function `numPaths` in the editor with the following parameter(s): - `warehouse[n][m]`: a two-dimensional array of integers with n rows and m columns Returns - `int`: the number of paths through the matrix, modulo (10^9 + 7) Constraints - 1 ≀ n, m ≀ 1000 - Each cell in matrix warehouse contains either a 0 or a 1

Asked in: DPWORLD

Image of the Question

Question Image Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| A company is organizing a batch process, where each batch consists of several t… |
| A digital art gallery has an art collection which is represented as a binary st… |
| Given a series of integer intervals, determine the size of the smallest set tha… |
| School renovation Given N classrooms in a school and each classroom has a ca… |
| Number in a range You are given three integers L, R, and K. A number X repre… |
| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |