Print the elements of an n x m matrix in spiral order.
Unlock detailed company stats for this questionUpgrade
Return the elements as a 1D array. Write it in an LLD style instead of a plain function: a Matrix class to store the grid, a TraversalStrategy interface and a SpiralTraversal class implementing the spiral logic.
Expect follow-ups like
- How would you support different traversal patterns in the future?
Community answers
No answers contributed by the community yet.


