time efficient

compare time efficiency of STL in c++ over normal way of coding?

The question is not clear.

STL provides you ample opportunities to cut down the length of the code and specifically focus on the task that needs to be done.

As far as time efficiency is concerned, lets take the example of std::sort()

The GNU Standard C++ library, for example, uses a 3-part hybrid sorting algorithm: introsort is performed first (introsort itself being a hybrid of quicksort and heap sort), to a maximum depth given by 2×log2 n, where n is the number of elements, followed by an insertion sort on the result

Source

It all depends on the task that you’re gonna be doing, to decide whether or not to take use of the STL.

Projects with strict memory requirements such as for embedded systems may not be suited for the STL, as it can be difficult to control and manage what's taken from and returned to the heap.

Meanwhile, in programming contests, why not use STL when it saves you time writing unnecessary code for the same. And STL plays a major role for the reason that C++ is one of the most widely used language in programming contests.

EDIT: Then, sorting a vector will be slower than an array variable as an array object, but same as the array variable as a pointer object.

Performance check here:

When this code (array as array object) was run with the output of this code, then it took 0.06 sec, whereas this (vector) took 0.09 sec.

1 Like

@bugkiller
for example we can take an int type array and a vector too of same type and then use std::sort on both of them,then which will be faster.
thanks in advance

@zealfire: Answer updated with example for the specific query

//