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 /largest_colour_val_dir_graph.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 'largest_colour_val_dir_graph.c')
-rw-r--r-- | largest_colour_val_dir_graph.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/largest_colour_val_dir_graph.c b/largest_colour_val_dir_graph.c index 79771bf..602fd48 100644 --- a/largest_colour_val_dir_graph.c +++ b/largest_colour_val_dir_graph.c @@ -105,11 +105,14 @@ int largestPathValue(char *colors, int **edges, int edgesSize, int main() { char *c1 = "abaca", *c2 = "a"; int e1i[4][2] = {{0, 1}, {0, 2}, {2, 3}, {3, 4}}, e2i[1][2] = {{0, 0}}; - struct two_d_arr e1, e2; - two_d_arr_init(&e1, ARRAY_SIZE(e1i), ARRAY_SIZE(e1i[0]), e1i); - two_d_arr_init(&e2, ARRAY_SIZE(e2i), ARRAY_SIZE(e2i[0]), e2i); - printf("%d\n", - largestPathValue(c1, e1.arr, e1.row_size, e1.col_size)); // expect: 3 - printf("%d\n", - largestPathValue(c2, e2.arr, e2.row_size, e2.col_size)); // expect: -1 + struct two_d_arr *e1 = + two_d_arr_init(ARRAY_SIZE(e1i), ARRAY_SIZE(e1i[0]), e1i); + struct two_d_arr *e2 = + two_d_arr_init(ARRAY_SIZE(e2i), ARRAY_SIZE(e2i[0]), e2i); + printf("%d\n", largestPathValue(c1, e1->arr, e1->row_size, + e1->col_size)); // expect: 3 + printf("%d\n", largestPathValue(c2, e2->arr, e2->row_size, + e2->col_size)); // expect: -1 + two_d_arr_free(e1); + two_d_arr_free(e2); } |