-
Notifications
You must be signed in to change notification settings - Fork 0
algocpp::algorithm::stalin_sort
sakamotor edited this page Aug 8, 2023
·
1 revision
Perform Stalin sort on std::vector
, etc.
Assuming the number of elements to be
#include <iostream>
#include <vector>
#include <algocpp/algorithm.hpp>
#include <algocpp/io.hpp>
using namespace std;
int main()
{
vector<int> A = {1, 3, 3, 5, 4, 7, 1, 9};
// [1, 3, 3, 5, 7, 9]
cout << algocpp::algorithm::stalin_sort(A, false) << endl;
// [1, 3, 5, 7, 9]
cout << algocpp::algorithm::stalin_sort(A, true) << endl;
}