Concept Flow - Count Occurrences of Element in Sorted Array
Start
Input: Sorted Array, Target Element
Find first occurrence index using binary search
Find last occurrence index using binary search
Calculate count = last_index - first_index + 1
Return count
End
We use two binary searches to find the first and last positions of the target element, then calculate how many times it appears.
