unknown Interview Question for Randoms
- 0of 0 votes
Given a square (n x n) matrix which only contains 0 and- danishm026 September 29, 2019 in India
1. Find the minimum cost to reach from left most column to rightmost column.
a. Starting point: You can start from any cell in the left most column i.e. (i, 0) where i can be between 0 and n( number of rows/ columns)
b. Destination: You can reach any cell in the rightmost column i. e ( k, n) where k can be anything between 0 and n.
c. You cannot visit a cell marked with 0.
d. Cost is defined as the sum of cells visited in path.
e. You can move up, down, left and right but not diagonally.
take 2x2 matrix
1 | 0
1 | 1
One possible path is 00 -- 10 -- 11 with cost 3
Other one is 10 -- 11 with cost 2
so minimum cost on this case is 2.
| Report Duplicate | Flag | PURGE
unknown Random Algorithm Data Structures
Interview Type: In-Person