A photo gallery's "story mode" reveals tiles in a spiral: along the top row left to right, down the right column, back along the bottom row, up the left column, and then the same for the inner tiles, until every tile is shown.
Write spiralRead(grid) that returns the tile values in that order.
Input: grid = [[2,4,6,8],[10,12,14,16],[18,20,22,24]] Output: [2,4,6,8,16,24,22,20,18,10,12,14]
The outer ring first, then the inner row 12, 14.
Input: grid = [[1],[2],[3]] Output: [1,2,3]
A single column is read straight down.
1 <= rows, cols <= 100Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #77 Spiral Read of a Tile Grid. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.