India’s Best Job Seekers and Training Platform › Forums › Algorithm Solutions Discussion › Let's say we have to find the tallest line of the horizon from a given 2D…..
Tagged: Algorithm, dropbox, Softwaredeveloper

Let's say we have to find the tallest line of the horizon from a given 2D…..

Let’s say we have to find the tallest line of the horizon from a given 2D array of the preprocessed image. The line starts at the leftmost column of the Matrix and end at the rightmost column of the matrix. To calculate the line you can only move left to right to 3 position, diagonally up , horizontally right and diagonally right i.e from a[i][j] you can move to a[i1][j+1], a[i][j+1] and a[i+1][j+1].
When moving to the right we need to pick the highest value in the cell. We will do this for every row in column 0 i.e a[0][j] then we will pick the smallest value of the path we have got. The answer will the smallest of the all values we got from traversing all the path
I know this bit vague and I had a hard time understanding the question but this what I understood
Lets say we have 3*3 array {{5,4,8}, {1,5,9}, {2,6,10}} . Now if we start from a[1][0] the possible path we can have
1 > 6 > 10 as we have to pick the highest value. Once we have this path we pick the smallest value on this path which is 1. We repeat this for all rows in a[i][0] than among all those values pick the smallest one
Find the best line from the matrix.
Log in to reply.