@jiminp/tooltool
    Preparing search index...

    Variable bisectConst

    bisect: (sorted_arr: (number | bigint)[], target: number) => number = bisectRight

    Type Declaration

      • (sorted_arr: (number | bigint)[], target: number): number
      • Locates the insertion point for target in sorted_arr to maintain sorted order. If target is already present, the insertion point is to the right of any existing entries.

        Parameters

        • sorted_arr: (number | bigint)[]

          The sorted array to search. Must be sorted in ascending order.

        • target: number

          The value to locate.

        Returns number

        The index where target should be inserted.

        • The time complexity is O(log n).
        • If the array is not sorted, the result is undefined.
        • This corresponds to Python's bisect_right.
        const arr = [1, 2, 4, 4, 6];
        bisectRight(arr, 4); // Returns 4
        bisectRight(arr, 3); // Returns 2