Deque-STL

  • + 0 comments

    This is my code which is fine but gives my "exceeded time limits", how can I solve this ?

    void printKMax(int arr[], int n, int k){
        deque<deque<int>> d;
        for(int i=0;i<(n-k+1);i++){
            deque<int> temp;
            for(int j=0;j<k;j++){
                temp.push_back(arr[i+j]);
            }
            d.push_back(temp);
        }
        for(deque<int> d1: d){
            auto itr = max_element(d1.begin(), d1.end());
            cout<<*itr<<" ";
        }
        cout<<endl;
    }