diff options
author | Jack Sangdahl <[email protected]> | 2025-08-27 12:45:33 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-08-27 12:45:33 -0600 |
commit | 4552bcf5a4a356415e248dee3b201f0cea7205bb (patch) | |
tree | 9868465918c6a6841b84cd14d66923b993dd9d62 /trapping_rain_water2.c | |
parent | f549305fb5ca531d29dce6c2c091560f44190443 (diff) | |
download | leetcode-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 'trapping_rain_water2.c')
-rw-r--r-- | trapping_rain_water2.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/trapping_rain_water2.c b/trapping_rain_water2.c index adde260..fdedd1e 100644 --- a/trapping_rain_water2.c +++ b/trapping_rain_water2.c @@ -85,11 +85,15 @@ int main() { {3, 2, 1, 2, 3}, {3, 2, 2, 2, 3}, {3, 3, 3, 3, 3}}; - struct two_d_arr hm1, hm2, hm3; - two_d_arr_init(&hm1, ARRAY_SIZE(hm1i), ARRAY_SIZE(hm1i[0]), hm1i); - two_d_arr_init(&hm2, ARRAY_SIZE(hm2i), ARRAY_SIZE(hm2i[0]), hm2i); + struct two_d_arr *hm1 = + two_d_arr_init(ARRAY_SIZE(hm1i), ARRAY_SIZE(hm1i[0]), hm1i); + struct two_d_arr *hm2 = + two_d_arr_init(ARRAY_SIZE(hm2i), ARRAY_SIZE(hm2i[0]), hm2i); printf("%d\n", - trapRainWater(hm1.arr, hm1.row_size, hm1.col_size)); // expect: 4 + trapRainWater(hm1->arr, hm1->row_size, hm1->col_size)); // expect: 4 printf("%d\n", - trapRainWater(hm2.arr, hm2.row_size, hm2.col_size)); // expect: 10 + trapRainWater(hm2->arr, hm2->row_size, hm2->col_size)); // expect: 10 + + two_d_arr_free(hm1); + two_d_arr_free(hm2); } |