Skip to content

Commit 41292a7

Browse files
committed
Fix(searches): Correct column pointer initialization
1 parent a8ad162 commit 41292a7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/com/thealgorithms/searches/RowColumnWiseSorted2dArrayBinarySearch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public <T extends Comparable<T>> int[] find(T[][] matrix, T key) {
2929

3030
public static <T extends Comparable<T>> int[] search(T[][] matrix, T target) {
3131
int rowPointer = 0; // The pointer at 0th row
32-
int colPointer = matrix.length - 1; // The pointer at end column
32+
int colPointer = matrix[0].length - 1; // The pointer at end column
3333

3434
while (rowPointer < matrix.length && colPointer >= 0) {
3535
int comp = target.compareTo(matrix[rowPointer][colPointer]);

0 commit comments

Comments
 (0)