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 /range_sum_query_2d.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 'range_sum_query_2d.c')
-rw-r--r-- | range_sum_query_2d.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/range_sum_query_2d.c b/range_sum_query_2d.c index 833f104..c0ce702 100644 --- a/range_sum_query_2d.c +++ b/range_sum_query_2d.c @@ -45,13 +45,12 @@ int main() { {1, 2, 0, 1, 5}, {4, 1, 0, 1, 7}, {1, 0, 3, 0, 5}}; - struct two_d_arr matrix; - two_d_arr_init(&matrix, 5, 5, matrix_input); + struct two_d_arr *matrix = two_d_arr_init(5, 5, matrix_input); NumMatrix *obj = - numMatrixCreate(matrix.arr, matrix.row_size, matrix.col_size); + numMatrixCreate(matrix->arr, matrix->row_size, matrix->col_size); printf("%d\n", numMatrixSumRegion(obj, 2, 1, 4, 3)); // expect: 8 printf("%d\n", numMatrixSumRegion(obj, 1, 1, 2, 2)); // expect: 11 printf("%d\n", numMatrixSumRegion(obj, 1, 2, 2, 4)); // expect: 12 numMatrixFree(obj); - two_d_arr_free(&matrix); + two_d_arr_free(matrix); } |