Problem
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
Java
solution by myself
Although it is slow, it is pass on Leetcode by myself after attempting six times.
1 | class Solution { |
Submission Detail
- 22 / 22 test cases passed.
- Runtime: 1 ms, faster than 6.37% of Java online submissions for Spiral Matrix.
- Memory Usage: 34.4 MB, less than 100.00% of Java online submissions for Spiral Matrix.
better solution
1 | class Solution { |
Submission Detail
- 22 / 22 test cases passed.
- Runtime: 0 ms, faster than 100.00% of Java online submissions for Spiral Matrix.
- Memory Usage: 34.2 MB, less than 100.00% of Java online submissions for Spiral Matrix.
C#
1 | public class Solution { |
Submission Detail
- 23 / 23 test cases passed.
- Runtime: 176 ms, faster than 71.81% of C# online submissions for Spiral Matrix.
- Memory Usage: 40.5 MB, less than 95.65% of C# online submissions for Spiral Matrix.