aboutsummaryrefslogtreecommitdiff
path: root/count_num_good_nodes.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 /count_num_good_nodes.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 'count_num_good_nodes.c')
-rw-r--r--count_num_good_nodes.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/count_num_good_nodes.c b/count_num_good_nodes.c
index 44879ed..58e9123 100644
--- a/count_num_good_nodes.c
+++ b/count_num_good_nodes.c
@@ -64,11 +64,12 @@ int main() {
int e1i[6][2] = {{0, 1}, {0, 2}, {1, 3}, {1, 4}, {2, 5}, {2, 6}};
int e2i[8][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 4},
{0, 5}, {1, 6}, {2, 7}, {3, 8}};
- struct two_d_arr e1, e2;
- two_d_arr_init(&e1, 6, 2, e1i);
- two_d_arr_init(&e2, 8, 2, e2i);
- printf("%d\n", countGoodNodes(e1.arr, e1.row_size, e1.col_size)); // expect: 7
- printf("%d\n", countGoodNodes(e2.arr, e2.row_size, e2.col_size)); // expect: 6
- two_d_arr_free(&e1);
- two_d_arr_free(&e2);
+ struct two_d_arr *e1 = two_d_arr_init(6, 2, e1i);
+ struct two_d_arr *e2 = two_d_arr_init(8, 2, e2i);
+ printf("%d\n",
+ countGoodNodes(e1->arr, e1->row_size, e1->col_size)); // expect: 7
+ printf("%d\n",
+ countGoodNodes(e2->arr, e2->row_size, e2->col_size)); // expect: 6
+ two_d_arr_free(e1);
+ two_d_arr_free(e2);
}