1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| A = [0,1,2,5,5,5,7,9]
print(lowerBound(A, 0, len(A), 5)) print(lowerBound(A, 0, len(A), 6)) print(lowerBound(A, 0, len(A), 0)) print(lowerBound(A, 0, len(A), 3))
print('upperBound') print(upperBound(A, -1, len(A)-1, 5)) print(upperBound(A, -1, len(A)-1, 6)) print(upperBound(A, -1, len(A)-1, 0)) print(upperBound(A, -1, len(A)-1, 3)) print(upperBound(A, -1, len(A)-1, 9))
print('upperInsert')
print(upperInsertId(A, 1, len(A), 5)) print(upperInsertId(A, 1, len(A), 6)) print(upperInsertId(A, 1, len(A), 0)) print(upperInsertId(A, 1, len(A), 3)) print(upperInsertId(A, 1, len(A), 8)) print(upperInsertId(A, 1, len(A), 9))
print('lowerInsert') print(lowerInsertId(A, -1, len(A)-1, 5)) print(lowerInsertId(A, -1, len(A)-1, 6)) print(lowerInsertId(A, -1, len(A)-1, 0)) print(lowerInsertId(A, -1, len(A)-1, 3)) print(upperInsertId(A, -1, len(A)-1, 8)) print(upperInsertId(A, -1, len(A)-1, 9))
|