The code in the video link is similar to the code that I've submitted but it misses an edge case


#1

When the array is 1 2 2 2 3 3 and if I search for 3 the answer will be 1 while it should be 2.

below is the code:
public class Solution {
// DO NOT MODIFY THE ARGUMENTS WITH “final” PREFIX. IT IS READ ONLY
public int findCount(final int[] a, int B) {
int first = search(a,B,true);
if (first == -1)
{
return 0;
}
int last = search(a,B,false);
return (last-first)+1;
}

public int search(int a[],int b, boolean first)
{
    int low = 0;
    int high= a.length-1;
    int result =-1;
    
    while (low<=high)
    {
        int mid = (low+high)/2;
        if (a[mid] == b)
        {
            result = mid;
            if (first)
            high = mid-1;
            else 
            low = mid+1;
        }
        else if (b<a[mid])
        high = mid-1;
        else 
        low = mid+1;
    }
    return result;
}

}

This successfully passes all the test cases though.