Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,297 views
in Online Assessments by Expert (46,090 points)
edited by | 1,297 views

2 Answers

0 like 0 dislike
Best answer

images of ques:

 

image


 

by Expert (46,090 points)
selected by
0 like 0 dislike
int minimumMemory(vector<int> process,int m){
    long long memo=0;
    long long maxi=0;
    long long sum=0;
    for(int i=0;i<k;i++){
        memo+=process[i];
        sum+=process[i];
    }
    maxi=max(memo,maxi);
    for(int i=k;i<process.size();i++){
        memo+=process[i]-process[i-k];
        maxi=max(memo,maxi);
          sum+=process[i];
    }
    return sum-maxi;
    
    
}
by Expert (46,090 points)