Limit Element Occurrences in Sorted Array - Coding problem | OneNoughtOne