Complexity change on using sort() C++ STL with comparator and without comparator

Правка en1, от kinitic013, 2023-07-26 21:14:24

Hello everyone

I was solving this problem on Leetcode (easy one), first I submitted my code with a comparator function to sort 2D vector using cmps() i.e. comparator function submission with comparator and then I submitted again without using comparator function as bydefault sort() sorted 2D vector based on first element of each vector element submission without comparator,on submission there's a huge gap in time taken as well as memory taken.

Can anyone help me/inform me how time/memory complexity changes with custom Comparator function.

By the way maximum size of vector element in 2D vector is 2 so more like vector of pair.

Теги c++, sort, stl, custom comparator

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский kinitic013 2023-07-26 21:14:24 925 Initial revision (published)