Time complexity of lua table.remove

Is the time complexity of table.remove(array, i) O(n)? Since it removes the value at index i and shuffles the index of all the values after it by 1. I can’t seem to find anything on this on google.
(This is important to me because I need to create a fast algorithm for a global matchmaking system I’m making)

1 Like

With table.remove it is O(n) in the worst case scenario.

There are some faster methods to remove elements from an (unsorted) array such as replacing the value at the index with the last one.

But table.remove is O(n).

3 Likes