You are viewing a single comment's thread. Return to all comments →
@serhii_nesteruk, :: has constant complexity, while ++ is linear. In your code you are applying ++ n times. First on the list of length 1, then 2, then 3, and so on. So overall complexity will be
::
++
O(1) + O(2) + ... + O(n-1) ~= O(n^2)
String Mingling
You are viewing a single comment's thread. Return to all comments →
@serhii_nesteruk,
::
has constant complexity, while++
is linear.In your code you are applying
++
n times. First on the list of length 1, then 2, then 3, and so on. So overall complexity will be