aboutsummaryrefslogtreecommitdiff
path: root/max_height_stacking_cuboids.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_height_stacking_cuboids.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_height_stacking_cuboids.c')
-rw-r--r--max_height_stacking_cuboids.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/max_height_stacking_cuboids.c b/max_height_stacking_cuboids.c
index 22417a4..2562b8c 100644
--- a/max_height_stacking_cuboids.c
+++ b/max_height_stacking_cuboids.c
@@ -63,12 +63,13 @@ int main() {
c2i[2][3] = {{38, 25, 45}, {76, 35, 3}},
c3i[6][3] = {{7, 11, 17}, {7, 17, 11}, {11, 7, 17},
{11, 17, 7}, {17, 7, 11}, {17, 11, 7}};
- struct two_d_arr c1, c2, c3;
- two_d_arr_init(&c1, 3, 3, c1i);
- two_d_arr_init(&c2, 2, 3, c2i);
- two_d_arr_init(&c3, 6, 3, c3i);
- printf("%d\n", maxHeight(c1.arr, c1.row_size, c1.col_size)); // expect: 190
- printf("%d\n", maxHeight(c2.arr, c2.row_size, c2.col_size)); // expect: 76
- printf("%d\n", maxHeight(c3.arr, c3.row_size, c3.col_size)); // expect: 102
- two_d_arr_free(&c1), two_d_arr_free(&c2), two_d_arr_free(&c3);
+ struct two_d_arr *c1 = two_d_arr_init(3, 3, c1i);
+ struct two_d_arr *c2 = two_d_arr_init(2, 3, c2i);
+ struct two_d_arr *c3 = two_d_arr_init(6, 3, c3i);
+ printf("%d\n", maxHeight(c1->arr, c1->row_size, c1->col_size)); // expect: 190
+ printf("%d\n", maxHeight(c2->arr, c2->row_size, c2->col_size)); // expect: 76
+ printf("%d\n", maxHeight(c3->arr, c3->row_size, c3->col_size)); // expect: 102
+ two_d_arr_free(c1);
+ two_d_arr_free(c2);
+ two_d_arr_free(c3);
}