 # Question 14

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 left-most 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[i-1][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[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 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] than among all those values pick the smallest one

Find the best line from the matrix.

## Ask Us How You Can Get Your First Dream Job Fill in the form below to book a 30 min no-obligation consulting session.