Whats the problem with this code?


#1

class Solution:
# @param A : tuple of integers
# @param B : integer
# @return an integer`

def findCount(self, A, B,):

    low=0
    high=len(A)-1
    print(high,low)
    while(low<high):
        mid=(high-low)/2> Blockquote
        if A[mid]==B:
            i=mid
            while(i<high):
                if A[i] == B:
                    c=c+1
                else:
                    break
                i=i+1                
            i=mid-1
            while(i>=0):
                if A[i] == B:
                    c=c+1
                else:
                    break
                i=i-1
            return c
        elif A[mid]<B:
            high=mid-1
        else:
            low=mid+1
    return -1

#2

Your code has worst case time complexity of order n i.e. O(n). This is the case when all the elements of array are same .