Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

04 Matrix -> 02 spirally traversing matrix #18

Open
FazeelUsmani opened this issue Dec 14, 2020 · 2 comments
Open

04 Matrix -> 02 spirally traversing matrix #18

FazeelUsmani opened this issue Dec 14, 2020 · 2 comments

Comments

@FazeelUsmani
Copy link
Owner

  1. Spirally traversing a matrix
    Medium Accuracy: 48.39% Submissions: 12583 Points: 4

Given a matrix of size R*C. Traverse the matrix in spiral form.

Example 1:

Input:
R = 4, C = 4
matrix[][] = {{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15,16}}
Output:
1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
Explanation:

Example 2:

Input:
R = 3, C = 4
matrix[][] = {{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}}
Output:
1 2 3 4 8 12 11 10 9 5 6 7
Explanation:
Applying same technique as shown above,
output for the 2nd testcase will be
1 2 3 4 8 12 11 10 9 5 6 7.

Your Task:
You dont need to read input or print anything. Complete the function spirallyTraverse() that takes matrix, R and C as input parameters and returns a list of integers denoting the spiral traversal of matrix.

Expected Time Complexity: O(RC)
Expected Auxiliary Space: O(R
C)

Constraints:
2 <= R, C <= 100
0 <= matrixi <= 100

@FazeelUsmani FazeelUsmani changed the title 04 -> 02 spirally traversing matrix 04 Matrix -> 02 spirally traversing matrix Dec 14, 2020
@cybergeekgyan
Copy link

Is this issue still open ? @FazeelUsmani

@FazeelUsmani
Copy link
Owner Author

Yes, @gyanprakash0221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants