You could look at it in a different way, transform the wall of bricks to a wall of edges, in your example it would be
1, 3, 5
3, 4
1, 4
2
3, 4
1, 4, 5
The first, the third and the last rowsrow have an edge at 1, thus you can draw a line that crosses three bricks less than the height of the wall. You need to find the edge that appears the most.
In this case it would be four it appears in rows 2,3,5,6.
After transforming the wall to a wall of edges, a SelectMany into a GroupBy and Max will do the trick.