Free written solutionBrick Wall (LeetCode 554): Solution and Explanation
Draw one vertical line through a wall of brick rows so it cuts as few bricks as possible. A line that runs along a seam between two bricks does not cut either one.
Read the intuition, approach, code and complexity →