O(1) in many cases involves a hashing function which is a non-trivial but constant cost. For smaller values of N it can be outperformed in terms of wall clock time by n^2 worst case algorithms.
In the example function that calls `indexOf` in a for..of loop, my mind went straight to the `join('\n')` when the newline delimiter could've been included in the string concatenation operation in the loop.
O(1) in many cases involves a hashing function which is a non-trivial but constant cost. For smaller values of N it can be outperformed in terms of wall clock time by n^2 worst case algorithms.
In the example function that calls `indexOf` in a for..of loop, my mind went straight to the `join('\n')` when the newline delimiter could've been included in the string concatenation operation in the loop.