Given an MxN matrix representing a city, as two different arrays int M[], int N[], where each element in each array represents the maximum height of the skyline in the city, return the max volume of the city.
The volume is calculated by the sum_ij where i < sizeOf M and j < size of N.
I used a depth first search at first but that wasn't right, I misunderstood the problem. Probably gonna get rejected. The matrix has to first be constructed where each element in the MxN matrix is the min value from each respective element of A and B since you have a threshold of the hight of the skyline.
Ex: A = [3, 4, 5], B = [5, 3, 3]
Matrix MxN:
{ [3, 3, 3]
[4, 3, 3]
[5, 3, 3]
}
The max volume would be the sum of all the elements in this matrix which is 30.
At the end the interviewer gave me some help, and you first need to create a function that creates the matrix by finding the minimum value at each (i, j) element in the corresponding A x B matrix.
You then need to traverse through and sum it all up to return the volume. It is a fairly simple problem, maybe a medium type problem or even easy. But my interviewer had a very thick accent and didn't explain it well. She also didn't copy/paste the prompt so I didn't really understand her.
At the end I came up with a functinon to find the threhold for the skyline at each element and just said we need to create it then have a running sum at each value. I am so mad I messed it up and overthought it.
This was for L3 (entry level)