Algorithm · Microsoft · Medium
Spiral Matrix Variants Medium · Topics · Company Tags · Hints You are given a two‑dimensional integer matrix with m rows and n columns. Your task is to collect every element from the matrix by visiting them in a clockwise spiral pattern and return the sequence as a flat list. Additionally, you must handle two variants: traversal in a counterclockwise spiral and building a spiral matrix from scratch. Task 1: Clockwise spiral traversal Starting at the top‑left corner, move…
Checking your access…