parameters: (self, left, right, threshold)
docstring: :type left: int
          :type right: int
          :type threshold: int
          :rtype: int
docstring_summary: :type left: int
          :type right: int
          :type threshold: int
          :rtype: int
docstring_tokens: : type left : int : type right : int : type threshold : int : rtype : int
function: def query(self, left, right, threshold):
          """
          :type left: int
          :type right: int
          :type threshold: int
          :rtype: int
          """
          def count(inv_idx, m, left, right):
              return bisect.bisect_right(inv_idx[m], right) - \
                     bisect.bisect_left(inv_idx[m], left)
  
          l, r = left//self.__bucket_size, right//self.__bucket_size;
          if l == r:
              m = self.__boyer_moore_majority_vote(self.__arr, left, right)
              if count(self.__inv_idx, m, left, right) >= threshold:
                  return m
              return -1
          else:
              m = self.__boyer_moore_majority_vote(self.__arr, left, (l+1)*self.__bucket_size-1)
              if count(self.__inv_idx, m, left, right) >= threshold:
                  return m
              m = self.__boyer_moore_majority_vote(self.__arr, r*self.__bucket_size, right)
              if count(self.__inv_idx, m, left, right) >= threshold:
                  return m;
              for i in xrange(l+1, r):
                  if count(self.__inv_idx, self.__bucket_majorities[i], left, right) >= threshold:
                      return self.__bucket_majorities[i]
              return -1
function_tokens: def query ( self , left , right , threshold ) : def count ( inv_idx , m , left , right ) : return bisect . bisect_right ( inv_idx [ m ] , right ) - bisect . bisect_left ( inv_idx [ m ] , left ) l , r = left // self . __bucket_size , right // self . __bucket_size if l == r : m = self . __boyer_moore_majority_vote ( self . __arr , left , right ) if count ( self . __inv_idx , m , left , right ) >= threshold : return m return - 1 else : m = self . __boyer_moore_majority_vote ( self . __arr , left , ( l + 1 ) * self . __bucket_size - 1 ) if count ( self . __inv_idx , m , left , right ) >= threshold : return m m = self . __boyer_moore_majority_vote ( self . __arr , r * self . __bucket_size , right ) if count ( self . __inv_idx , m , left , right ) >= threshold : return m for i in xrange ( l + 1 , r ) : if count ( self . __inv_idx , self . __bucket_majorities [ i ] , left , right ) >= threshold : return self . __bucket_majorities [ i ] return - 1