aboutsummaryrefslogtreecommitdiff
path: root/Computer_Science/leetcode/59-spiral_matrix_II.c~
diff options
context:
space:
mode:
Diffstat (limited to 'Computer_Science/leetcode/59-spiral_matrix_II.c~')
-rw-r--r--Computer_Science/leetcode/59-spiral_matrix_II.c~17
1 files changed, 17 insertions, 0 deletions
diff --git a/Computer_Science/leetcode/59-spiral_matrix_II.c~ b/Computer_Science/leetcode/59-spiral_matrix_II.c~
new file mode 100644
index 0000000..7276575
--- /dev/null
+++ b/Computer_Science/leetcode/59-spiral_matrix_II.c~
@@ -0,0 +1,17 @@
+/**
+ * Return an array of arrays.
+ * Note: The returned array must be malloced, assume caller calls free().
+ */
+int** generateMatrix(int n) {
+ int **matrix = malloc(sizeof(int *) * n);
+ int offset = 0;
+ int maxOffset = n / 2 + 1;
+
+ for(int i = 0; i < n; i++)
+ *(matrix + i) = malloc(sizeof(int) * n);
+ for(offset = 0; offset < maxOffset; offset++, n -= 2) {
+ if(n == 0)
+ return;
+ else if(n == 1)
+ matrix
+}