diff options
Diffstat (limited to 'src/util/array.py')
-rw-r--r-- | src/util/array.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/array.py b/src/util/array.py new file mode 100644 index 0000000..7dd0357 --- /dev/null +++ b/src/util/array.py @@ -0,0 +1,5 @@ +def insert_position(x, xs, is_reversed: bool) -> int: + for i, y in enumerate(xs): + if is_reversed and x > y or not is_reversed and x < y: + return i + return len(xs) |