You are viewing a single comment's thread. Return to all comments →
/* * Write your code here. */ Arrays.sort(keyboards); Arrays.sort(drives); int res=0; for(int i=keyboards.length-1;i>=0;i--){ System.out.println(keyboards[i]); if((b-keyboards[i])>0){ int dr=getDrive(keyboards[i],drives,b); System.out.println(dr+" "+keyboards[i]); if(dr>0 && (keyboards[i]+dr)>res) res=(keyboards[i]+dr); } } if(res>0) return res; return -1; } static int getDrive(int keyp,int[] d,int b){ for(int j=d.length-1;j>=0;j--){ if(keyp+d[j]<=b) { return d[j]; } } return -1; }
Seems like cookies are disabled on this browser, please enable them to open this website
Electronics Shop
You are viewing a single comment's thread. Return to all comments →