How the time complexity of code A is greater than code B

I was solving Number Theory quiz I, in question 4, there are shown 2 codes: code A and code B.

The only difference is that,

In code A, the vector is passed by value,

In code B, the vector is passed by reference.

In the answer, code A is given more time complexity. Why?

@siddharth_1_3277 when passed by value whole vector gets copied so takes n times in doing so and when passed by ref takes 0(1) time.
i hope its cleared if yes dont forget to mark doubt resolved and hit like :smiley:

1 Like