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 /max_subarr_remove_conflict_pair.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 'max_subarr_remove_conflict_pair.c')
-rw-r--r-- | max_subarr_remove_conflict_pair.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/max_subarr_remove_conflict_pair.c b/max_subarr_remove_conflict_pair.c index a225f61..8e0d9b3 100644 --- a/max_subarr_remove_conflict_pair.c +++ b/max_subarr_remove_conflict_pair.c @@ -50,11 +50,14 @@ long long maxSubarrays(int n, int **conflictingPairs, int conflictingPairsSize, int main() { int cp1i[2][2] = {{2, 3}, {1, 4}}, cp2i[3][2] = {{1, 2}, {2, 5}, {3, 5}}; - struct two_d_arr cp1, cp2; - two_d_arr_init(&cp1, ARRAY_SIZE(cp1i), ARRAY_SIZE(cp1i[0]), cp1i); - two_d_arr_init(&cp2, ARRAY_SIZE(cp2i), ARRAY_SIZE(cp2i[0]), cp2i); + struct two_d_arr *cp1 = + two_d_arr_init(ARRAY_SIZE(cp1i), ARRAY_SIZE(cp1i[0]), cp1i); + struct two_d_arr *cp2 = + two_d_arr_init(ARRAY_SIZE(cp2i), ARRAY_SIZE(cp2i[0]), cp2i); printf("%lld\n", - maxSubarrays(4, cp1.arr, cp1.row_size, cp1.col_size)); // expect: 9 + maxSubarrays(4, cp1->arr, cp1->row_size, cp1->col_size)); // expect: 9 printf("%lld\n", - maxSubarrays(5, cp2.arr, cp2.row_size, cp2.col_size)); // expect: 12 + maxSubarrays(5, cp2->arr, cp2->row_size, cp2->col_size)); // expect: 12 + two_d_arr_free(cp1); + two_d_arr_free(cp2); } |