educative.io

Educative

Time complexity question Doubt in Big-O notation

Hello,

In the Big O notation topic, I see Challenge-6 and Challenge-7 to be same however the solution is proposed differently. Could you please explain?

Hi Kishore,
The difference between these two solutions is their time complexity. In challenge 6(advanced), time complexity is O(nlog2(n)), while in challenge 7(pro), time complexity is O(n). The time complexity of pro solution is better than the advanced solution.
O(n) < O(nlogn)