8053535 | CodeChef

Please have a look at this problem.
In this problem if I do using O(n) algorithm, what will be the overall time complexity of this problem?

I mean do we consider test cases.
Let say 1 <= T <= 1000 & 1 <= n <= 10^6. These are the constraints given in the problem then If I use O(n), the overall Time Complexity would be O(t * n) or only O(n). Do we not consider the computation for test cases?

Please clarify this doubt.


Consider a number N , total no. of digits in number = log(n)(base 10)+1.
Eg : 1234 => log(1234)(base 10) + 1 = 4(Integer value)
Hence the overall time complexity for reversing the number = O(logn).{since, log (n) + 1 digits}
Considering the test cases : O(t*logn)

The algorithm is not dependent on n, but on the number of digits in n i.e O(log n), like @nbb7 said.

However, if the question said to reverse an n-digit number where 1<=n<=100000 then yes this algorithm fails.