diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/spiral_matrix2.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/spiral_matrix2.cpp')
-rw-r--r-- | other/spiral_matrix2.cpp | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/other/spiral_matrix2.cpp b/other/spiral_matrix2.cpp deleted file mode 100644 index dc8dc11..0000000 --- a/other/spiral_matrix2.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// 59. Spiral Matrix II -#include "leetcode.h" - -// given a positive integer 'n', generate an n x n 'matrix' filled with -// elements from 1 to 'n^2' in spiral order - -class Solution { -public: - vvd generateMatrix(int n) { - vvd matrix(n, vector<int>(n)); - int num = 1, row = 0, col = 0, dir = 0; - vector<int> d_r = {0, 1, 0, -1}, d_c = {1, 0, -1, 0}; - while (num <= n * n) { - matrix[row][col] = num; - num++; - int next_row = row + d_r[dir]; - int next_col = col + d_c[dir]; - if (next_row < 0 || next_row >= n || next_col < 0 || next_col >= n || - matrix[next_row][next_col]) - dir = (dir + 1) % 4; - row += d_r[dir]; - col += d_c[dir]; - } - return matrix; - } -}; |