Commiting a code to find number of occurences in a sorted array