aboutsummaryrefslogtreecommitdiff
path: root/max_area_longest_diag_rect.c
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-08-27 12:45:33 -0600
committerJack Sangdahl <[email protected]>2025-08-27 12:45:33 -0600
commit4552bcf5a4a356415e248dee3b201f0cea7205bb (patch)
tree9868465918c6a6841b84cd14d66923b993dd9d62 /max_area_longest_diag_rect.c
parentf549305fb5ca531d29dce6c2c091560f44190443 (diff)
downloadleetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.tar.gz
leetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.zip
chore: Refactor two_d_arr_init function
Return a pointer to a new struct, rather than initialise objects in an existing struct
Diffstat (limited to 'max_area_longest_diag_rect.c')
-rw-r--r--max_area_longest_diag_rect.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/max_area_longest_diag_rect.c b/max_area_longest_diag_rect.c
index 3aa7c8e..78ec1e1 100644
--- a/max_area_longest_diag_rect.c
+++ b/max_area_longest_diag_rect.c
@@ -25,13 +25,14 @@ int areaOfMaxDiagonal(int **dimensions, int dimensionsSize,
int main() {
int d1i[2][2] = {{9, 3}, {8, 6}}, d2i[2][2] = {{3, 4}, {4, 3}};
- struct two_d_arr d1, d2;
- two_d_arr_init(&d1, ARRAY_SIZE(d1i), ARRAY_SIZE(d1i[0]), d1i);
- two_d_arr_init(&d2, ARRAY_SIZE(d2i), ARRAY_SIZE(d2i[0]), d2i);
+ struct two_d_arr *d1 =
+ two_d_arr_init(ARRAY_SIZE(d1i), ARRAY_SIZE(d1i[0]), d1i);
+ struct two_d_arr *d2 =
+ two_d_arr_init(ARRAY_SIZE(d2i), ARRAY_SIZE(d2i[0]), d2i);
printf("%d\n",
- areaOfMaxDiagonal(d1.arr, d1.row_size, d1.col_size)); // expect: 48
+ areaOfMaxDiagonal(d1->arr, d1->row_size, d1->col_size)); // expect: 48
printf("%d\n",
- areaOfMaxDiagonal(d2.arr, d2.row_size, d2.col_size)); // expect: 12
- two_d_arr_free(&d1);
- two_d_arr_free(&d2);
+ areaOfMaxDiagonal(d2->arr, d2->row_size, d2->col_size)); // expect: 12
+ two_d_arr_free(d1);
+ two_d_arr_free(d2);
}