3
int leastBricks(vector<vector<int>> &wall) {4
unordered_map<int, int> edge_frequency; // HashMap to store the number of5
// common edges among the rows6
int max_frequency = 0; // Variable to store the frequency of most occuring edge8
for (int row = 0; row < wall.size(); row++) // Iterating through each row10
int edge_postion = 0; // Variable to store different edge postion12
for (int brick_no = 0; brick_no < wall[row].size() - 1;13
brick_no++) // Iterating through each brick inside a row15
int current_brick_length = wall[row][brick_no]; // Length of the current brick17
edge_postion + current_brick_length; // Next Edge Position = Previous Edge Position18
// + Current Brick's Length19
edge_frequency[edge_postion]++; // Incrementing the Frequency of just20
// calculated Edge Postion21
max_frequency = max(edge_frequency[edge_postion],22
max_frequency); // Comparing the "Frequency of just calculated23
// Edge Postion" with "Max Frequency seen till24
// now" & storing whichever is greater.27
return wall.size() - max_frequency; // returning (Number of Bricks Crossed28
// by Line) i.e. (Number of Rows in Wall29
// - Frequency of Most Occuring Edge)