Skip to content

Commit c26cab4

Browse files
author
rvuyyuru7
committed
Corrected the comment
1 parent 7254a1c commit c26cab4

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Problem1.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@ public int search(int[] arr) {
1818
left = mid + 1;
1919
}
2020
}
21-
return left + 1; // left pointer always stops one index before the missing number
21+
// Left pointer always stops at the index where missing number should be.
22+
// Number at the index should be index + 1.
23+
return left + 1;
2224
}
2325

2426
public static void main(String[] args) {
2527
Solution ob = new Solution();
2628
int[] arr = new int[] {1, 2, 3, 5, 6, 7, 8};
27-
System.out.println(ob.search(arr));
29+
System.out.println(ob.search(arr)); // returns 4
2830
int[] arr1 = new int[] {1, 2, 4, 5, 6, 7, 8, 9};
29-
System.out.println(ob.search(arr1));
31+
System.out.println(ob.search(arr1)); // retuns 3
3032
int[] arr3 = new int[] {2, 3, 4, 5, 6, 7, 8, 9};
31-
System.out.println(ob.search(arr3));
33+
System.out.println(ob.search(arr3)); // returns 1
3234
int[] arr4 = new int[] {1, 2, 3, 4, 5, 6, 7, 8};
33-
System.out.println(ob.search(arr4));
35+
System.out.println(ob.search(arr4)); // returns 9
3436
}
3537
}

0 commit comments

Comments
 (0)