← ALL NOTES
Array

54. Spiral Matrix

Track four shrinking boundaries — top, bottom, left, right — and peel one edge at a time, moving the boundary inward after each. Top row left-to-right, then top++; right column top-to-bottom, then…

Loading…