# Vmware Interview Question

This is the question recently asked for the Vmware MTS-2 Position from me.

You will be given a list of articles with their page lengths and intellectual value coefficients. Given a limit to the number of pages you can read in a day, determine the maximum intellectual value you can achieve during one day.

For example, your articles are of lengths *articles =[2,2,3,4]* and they are of intellectual value *iv =[2,4,4,5].* If you can read *p=15* pages in a day, what should you read? You have to read each article twice to gain value.Associating 2**articles[i]* with *iv[i]*, The maximum combined length of articles read twice is*14* pages and there are two ways to get there: read*articles[0], articles[1] and articles[2]* for a total intellectual value of 2 + 4 + 4 = 10 or read *articles[2]*and *articles[3]* for a total of 4 + 5 = 9. Our maximal learning is 10 intellectual value points.

Complete the function maximum learning*.* The function must return the integer value representing the maximum intellectual value you can get in one day of reading.

This is the simple question of 0–1 Knapsack.

Below is the implementation.

publicstaticintmaximumLearning(List<Integer> iv, List<Integer> articles,intp) {intsize = articles.size();int[] art =newint[size];int[] ivs =newint[size];for(inti=0;i<size;i++){

art[i] = articles.get(i)*2;

ivs[i] = iv.get(i);

}returnknapSackTopDownCode(ivs, art, p, size);

}publicstaticintknapSackTopDownCode(int[] val,int[] wt,intW,intn) {intmat[][] =newint[n+1][W+1];for(inti=1;i<n+1;i++) {for(intj=1;j<W+1;j++) {if(i==0 || j ==0)

mat[i][j] =0;

elseif(wt[i-1]<=j) {

mat[i][j] = Math.max(val[i-1]+ mat[i-1][j-wt[i- 1]],mat[i-1][j]);

}

else{

mat[i][j] = mat[i-1][j];}

}

}

returnmat[n][W];

}

}

Happy Coding!!