Mridul-1-Sharma / data_structures_algos

Contribute to this repository with valid pull request to Hacktoberfest 2022 and earn awesome swags & T-shirts. This is a beginner friendly Project.
MIT License
6 stars 27 forks source link

Spiral Matrix solution added #39

Closed Aditya-chaki closed 1 year ago

Aditya-chaki commented 1 year ago

DESCRIPTION First, four variables containing the indices for the corner points of the array are initialized.

The algorithm starts from the top left corner of the array, and traverses the first row from left to right. Once it traverses the whole row it does not need to revisit it, thus, it increments the top corner index.

Once complete, it traverses the rightmost column top to bottom. Again, once this completes, there is no need to revisit the rightmost column, thus, it decrements the right corner index.

Next, the algorithm traverses the bottommost row and decrements the bottom corner index afterward.

Lastly, the algorithm traverses the leftmost column, incrementing the left corner index once it’s done.

This continues until the left index is greater than the right index, and the top index is greater than the bottom index.

Aditya-chaki commented 1 year ago

@Mridul-1-Sharma Sir please review my changes under Hacktoberfest 2022.