Log In

You have written code that goes through the outer edge of a square matrix. Can you write code that first goes through the outer edge, and then through the next most outer edge?

For example, given this input:
ABCDE
FGHIJ
KLMNO
PQRST
UVWXY

The output of the function would be:
["A","B","C","D","E","J","O","T","Y","X","W","V","U","P","K","F","G","H","I","N","S","R","Q","L"]

In this case, only the M would not be traversed.

For now, it is fine to simply make 4 more loops for . In the next step, we can think about how to generalize the full spiral.

Sign Up or Log In to access the code editor and answer the question!
Log In