@jiminp/tooltool
    Preparing search index...

    Function bisectLeft

    • Finds the leftmost insertion point for target in a sorted array.

      If target exists, returns the index before any equal entries. (Like Python's bisect_left.)

      Parameters

      • sorted_arr: (number | bigint)[]

        Sorted array (ascending).

      • target: number

        Value to locate.

      Returns number

      Insertion index.

      O(log n). Behavior is undefined if array is not sorted.

      bisectLeft([1, 2, 4, 4, 6], 4); // 2
      bisectLeft([1, 2, 4, 4, 6], 3); // 2