SortedSearch


Algorithmic thinking Searching Public

Hard  

20min


Implement function countNumbers that accepts a sorted array of integers and counts the number of array elements that are less than the parameter lessThan.

For example, SortedSearch.countNumbers(new int[] { 1, 3, 5, 7 }, 4) should return 2 because there are two array elements less than 4.

 
 


  •   Example case: java.lang.UnsupportedOperationException at SortedSearch.countNumbers(SortedSearch.java:3)
  •   Various small arrays: java.lang.UnsupportedOperationException at SortedSearch.countNumbers(SortedSearch.java:3)
  •   Performance test when sortedArray contains lessThan: java.lang.UnsupportedOperationException at SortedSearch.countNumbers(SortedSearch.java:3)
  •   Performance test when sortedArray doesn't contain lessThan: java.lang.UnsupportedOperationException at SortedSearch.countNumbers(SortedSearch.java:3)