So I've got a problem with one task.
You have given sequence of numbers and n operations in each there are two numbers (indexes in this given sequence).
You have to check if sequence after each operation will be sorted or not. (Every operation is applied).
My problem is that my solution is too slow. It works in O(n^2). (I'm just making swap and using is_sorted from c++11). How to make it faster ?
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire