• Challenge Author
    + 1 comment

    @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)