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 -> 03 Boundary traversal of matrix #19

Closed
FazeelUsmani opened this issue Dec 14, 2020 · 7 comments
Closed

04 Matrix -> 03 Boundary traversal of matrix #19

FazeelUsmani opened this issue Dec 14, 2020 · 7 comments

Comments

@FazeelUsmani
Copy link
Owner

  1. Boundary traversal of matrix
    Easy Accuracy: 45.05% Submissions: 9917 Points: 2

You are given a matrix of dimensions n x m. The task is to perform boundary traversal on the matrix in a clockwise manner.

Example 1:

Input:
n = 4, m = 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
Explanation:
The matrix is:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
The boundary traversal is:
1 2 3 4 8 12 16 15 14 13 9 5

Example 2:

Input:
n = 3, m = 4
matrrix[][] = {{12, 11, 10, 9},
{8, 7, 6, 5},
{4, 3, 2, 1}}
Output: 12 11 10 9 5 1 2 3 4 8

Your Task:
Complete the function boundaryTraversal() that takes matrix, n and m as input parameters and returns the list of integers that form the boundary traversal of the matrix in a clockwise manner.

Expected Time Complexity: O(N + M)
Expected Auxiliary Space: O(1)

Constraints:
1 <= n, m<= 100
0 <= matrixi <= 1000

@EmelyChhu
Copy link
Contributor

Hi! Can I contribute to this issue?

@Sahil280599
Copy link
Contributor

@EmelyChhu Definitely

@FazeelUsmani
Copy link
Owner Author

@EmelyChhu You can add your solution, raise a PR, and add me for a review.

@EmelyChhu
Copy link
Contributor

@FazeelUsmani Thank you, I'll get that done within the next few days.

@EmelyChhu
Copy link
Contributor

EmelyChhu commented Feb 2, 2024

@FazeelUsmani I see there is already a solution in boundaryTraversalMatrix.cpp should I make another solution? I have finished a solution, but I do not have commit permissions. How should I raise the PR?

@EmelyChhu
Copy link
Contributor

EmelyChhu commented Feb 7, 2024

I was able to figure out how to create a PR from a fork. This is the link to the PR: #102

@FazeelUsmani
Copy link
Owner Author

Thanks! I've merged it

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

No branches or pull requests

3 participants