neetcode-gh/leetcode

Bug Report for python-sort-ascending

Closed this issue · 0 comments

Bug Report for https://neetcode.io/problems/python-sort-ascending

insert_at will pass all tests even if the user did not implement checking if the index is valid.

def insert_at(arr: List[int], index: int, element: int) -> List[int]:
arr.insert(index, element)

will work

to fix, add a test where insert_at is called with an out-of-bounds index:

e.g. print(insert_at([1, 2, 3, 4, 5], 6, 6))