def query(self, i: int, j: int) -> int:
if j <= i:
return -1
if j - i == 1:
return i
j = min(j, len(self.array))
k = numpy.zeros((2,), dtype=numpy.int32)
values = numpy.zeros((2,))
l = int(numpy.log2(j - i))
col = max(0, l-1)
k[0] = self.table[i, col]
k[1] = self.table[j - 2**l, col]
values[0] = self.array[k[0]]
values[1] = self.array[k[1]]
return k[self.func(values)]
评论列表
文章目录