Create Counting no of occurences in a sorted array