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 /find_kth_large_xor_coord.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 'find_kth_large_xor_coord.c')
-rw-r--r-- | find_kth_large_xor_coord.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/find_kth_large_xor_coord.c b/find_kth_large_xor_coord.c index 2611be1..e8bfe81 100644 --- a/find_kth_large_xor_coord.c +++ b/find_kth_large_xor_coord.c @@ -29,14 +29,16 @@ int kthLargestValue(int **matrix, int matrixSize, int *matrixColSize, int k) { int main() { int matrix_input[2][2] = {{5, 2}, {1, 6}}; - struct two_d_arr matrix; - two_d_arr_init(&matrix, ARRAY_SIZE(matrix_input), ARRAY_SIZE(matrix_input[0]), - matrix_input); - printf("%d\n", kthLargestValue(matrix.arr, matrix.row_size, matrix.col_size, - 1)); // expect: 7 - printf("%d\n", kthLargestValue(matrix.arr, matrix.row_size, matrix.col_size, - 2)); // expect: 5 - printf("%d\n", kthLargestValue(matrix.arr, matrix.row_size, matrix.col_size, - 3)); // expect: 4 - two_d_arr_free(&matrix); + struct two_d_arr *matrix = two_d_arr_init( + ARRAY_SIZE(matrix_input), ARRAY_SIZE(matrix_input[0]), matrix_input); + printf("%d\n", + kthLargestValue(matrix->arr, matrix->row_size, matrix->col_size, + 1)); // expect: 7 + printf("%d\n", + kthLargestValue(matrix->arr, matrix->row_size, matrix->col_size, + 2)); // expect: 5 + printf("%d\n", + kthLargestValue(matrix->arr, matrix->row_size, matrix->col_size, + 3)); // expect: 4 + two_d_arr_free(matrix); } |