Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f62e213

Browse files
author
Ram swaroop
committed
smallest missing number : minor fix
1 parent a5afb1d commit f62e213

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/me/ramswaroop/arrays/SmallestMissingNumber.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class SmallestMissingNumber {
3030
* @return
3131
*/
3232
public static int smallestMissingNumber(int[] a, int low, int high) {
33-
if (low < high) {
33+
if (low <= high) {
3434
int mid = (low + high) / 2;
3535

3636
if (a[mid] == mid) {
@@ -46,9 +46,11 @@ public static int smallestMissingNumber(int[] a, int low, int high) {
4646
}
4747

4848
public static void main(String a[]) {
49+
System.out.println(smallestMissingNumber(new int[]{0, 1}, 0, 1));
4950
System.out.println(smallestMissingNumber(new int[]{0, 1, 2, 6, 9}, 0, 4));
5051
System.out.println(smallestMissingNumber(new int[]{4, 5, 10, 11}, 0, 3));
52+
System.out.println(smallestMissingNumber(new int[]{0, 4, 5, 10, 56}, 0, 4));
5153
System.out.println(smallestMissingNumber(new int[]{0, 1, 2, 3, 4, 5, 6, 7, 10}, 0, 8));
52-
System.out.println(smallestMissingNumber(new int[]{0, 1, 3, 3, 11}, 0, 4)); // doesn't work
54+
System.out.println(smallestMissingNumber(new int[]{0, 1, 2, 3, 3}, 0, 4)); // doesn't work
5355
}
5456
}

0 commit comments

Comments
 (0)