Time complexity
Time complexity measures, or estimates, the time by counting the number of elementary operations. It assumes that performing an elementary operation takes a fixed amount of time. To get a fixed amount of time, you can assume either worst-case complexity or average complexity.
Most commonly, the big O notation is used to express time complexity; for instance, O(1) or O(n):

Let's look at the time complexity of the collections from the JDK.
Calculating time complexity
Let's look at the next example:
inline fun operation(n: Int, statement: () -> Unit) { for (i in 0..n) { statement() } }
The execution time of the statement is constant. The time complexity of the preceding code is linear, or O(n) if we're using big O notation. We can rewrite the operation
function as follows:
inline fun operation(n: Int, statement: () -> Unit) { for (i in 0..n) { for (k in 0..n) { statement() } } }
When we do, we'll get a quadratic time complexity that can be...