Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. void array_set_to_list(const std::vector<std::list<int>> &src, std::list<int> &dst){
  2.  
  3.     for(int i = 0; i < src.size();i++){
  4.         if(src[i].size() <= 4 && std::is_sorted(src[i].begin(),src[i].end())){
  5.             std::list<int> temp;
  6.             for(auto j:src[i]){
  7.                 temp.push_back(j);
  8.                 temp.reverse();
  9.             }
  10.             if(dst.empty()){
  11.                 dst.splice(dst.begin(),temp);
  12.                 temp.clear();
  13.             }
  14.             else{
  15.                 dst.merge(temp);
  16.                 temp.clear();
  17.             }
  18.         }
  19.     }
  20.     for(auto l:dst){
  21.         cout << l <<' ';
  22.     }
  23.     cout << endl;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement