Skip to content

Commit f8f8d1c

Browse files
Update Interview3
1 parent 57327ae commit f8f8d1c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/main/java/pramp/Interview3

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
// {0} - 0
1+
2+
/**
3+
* Given an array of integer return an index where the value stored at it is the same as the index.
4+
* If no such value exists, return -1. Assume that the array is sorted in ascending order.
5+
*
6+
* @author: shivam.maharshi
7+
*/
8+
9+
public class Pramp {
10+
11+
// {0} - 0
212
// {-1, 1} - 1
313
// {-1, 2} - -1
414
// {3, 4} - -1
@@ -16,3 +26,5 @@
1626
int m = (h - l)/2 + l;
1727
return a[m] == m ? m : ( a[m] > m ? get(a, l, m) : get(a, m + 1, h));
1828
}
29+
30+
}

0 commit comments

Comments
 (0)