ts-ds / lowerBound
Function: lowerBound()
ts
function lowerBound<T>(
array,
target,
compareFn?
): number;Defined in: search/search.ts:41
Index of the first element that is not less than target in a sorted array — the position where target can be inserted keeping the order. Binary search: halves the range each step.
| Time | Memory |
|---|---|
| O(log n) | O(1) |
Type Parameters
| Type Parameter | Description |
|---|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
array | readonly T[] | undefined | Array sorted in the order of compareFn. |
target | T | undefined | Value to look for. |
compareFn? | CompareFn<T> | defaultCompare | Order of the array. |
Returns
number
From 0 to array.length.