Paths in a Warehouse A forklift worker moves products from one place to the other in an automotive parts warehouse. There a map in the dashboard that shows, in real time, the open and blocked sections...



Paths in a Warehouse A forklift worker moves products from one place to the other in an automotive parts warehouse. There a map in the dashboard that shows, in real time, the open and blocked sections inside the warehouse. The map is displayed as an nxm matrix of 1's and O's which represent open and blocked sections respectively. A forklift driver always starts at the upper left corner of the map at warehouse[0][0] and tries to reach the bottom right section of the map or warehouse[n-1][m-1). Each movement must be in increasing value along a row or column but not both. Given the warehouse map, determine the number of distinct paths to get from warehouse[0][0] to warehouse[n-1][m-1). The number may be large, so return the value modulo (109+7). Language Java 8 • Autocomplete Ready 1 > import java.io.*; - 14 15 class Result { 16 17 /* 18 * Complete the numPaths' function below. 19 20 * The function is expected to return an INTEGER. 21 * The function accepts 2D_INTEGER_ARRAY warehouse as parameter. 22 23 24 public static int numPaths List> warehouse) { 25 // Write your code here 26 27 1 28 29 } 30 31 > public class Solution VANU Example warehouse = [1, 1, 0, 1), 11, 1, 1, 1] The matrix below is drawn from the warehouse array showing open and blocked sections of the warehouse 1 indicates an open section and O indicates a blocked section. It is only possible to travel through open sections, so no path can go through the section at (0, 2). Possible Paths 0 1 2 3 0 1 2 3 0 1 1 0 1 0 1 1 1 1 1 Line: 14 Col: 1 1 1 1 1 1 1 1 Test Custom Run Run Submit Possible Paths 0 1 2 3 0 1 2 3 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 There are 2 possible paths from warehouse[0][0] to warehouse[1][3] and 2 modulo (109+7)= 2. Function Description Complete the function numPaths in the editor below. numPaths has the following parameter(s): warehouse[n][m]: a two dimensional array of integers of n rows and m columns Returns: int: the number of paths through the matrix, modulo (109 + 7). Constraints . 15 nm s 1000 • Each cell in matrix a contains either a O or a 1. Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer n, the number of rows in the matrix warehouse. The next line contains an integer m, the number of columns in the matrix warehouse. The next n lines each contain a string warehouse[i] where 0 si


Oct 14, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here