edges
to store the frequency of each cumulative width (edge) encountered.maxEdges
to 0 to keep track of the maximum number of edges aligned.currentWidth
to 0, which will store the cumulative width as we go through the bricks in the current row.
b. Iterate over the bricks in the current row, excluding the last brick:
i. Add the width of the current brick to currentWidth
.
ii. Increment the count for currentWidth
in the edges
HashMap.
iii. Update maxEdges
to be the maximum of itself and the count for currentWidth
.maxEdges
.